jquery - Click specific div element that is closest to my span tag -


i wrote function returns 4 different span elements multiple choice. wrote function selects answer.

i'm not sure how can hook these 2 pieces together.

here spans returned

<span class="choice-label" data-bind=​"text:​ fact.value">​randy thompson</span>​ <span class=​"choice-label" data-bind=​"text:​ fact.value">​colton roberts​</span>​ <span class=​"choice-label" data-bind=​"text:​ fact.value">​eric stavers​</span>​ <span class=​"choice-label" data-bind=​"text:​ fact.value">​jessica linglong​</span>​ 

my other functions returns first name only, example 'eric'

each span above surrounded div btn btn-class.

how pick out span matches 'eric'.

here function grabs name later used

var s = $("div.card-content[data-bind='resizedimage: questionfact.value']").css('background-image'); var n = s.indexof('-'); s = s.substring(0, n != -1 ? n : s.length); s.replace('url("http://mytestsite.com/testcase/', '');  s == eric 

so s need click on span above closest div class of btn btn-class

here use pull out 4 different​ spans. $('div .answer span')

i've tried $('div .answer span:contains(eric)') doesn't work. not sure missing.

try $("div .answer span:contains('eric')") (contains case sensitive)


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -