Reputation: 10586
I'm trying to find out how to select all <span class="title">
elements on the page:
<div class="my-page">
<span class="title">first</span>
<span class="title">second</span>
<span class="title">third</span>
<span class="title">fourth</span>
<span class="title">fifth</span>
</div>
that are present on the list (fetched from servlet in JSON format) and stored inside some variable?
I've tried something like:
success : function(data, statusText, jqxhr) {
var arr = data.selectedTitles;
jQuery.each(data.favTools, function(i, v) {
var title = v;
jQuery('span.title:contains(title)').css("text-decoration", "underline");
});
}
Upvotes: 0
Views: 628
Reputation: 318518
$('span.title').filter(function() {
return $(this).text().indexOf(title) != -1;
});
Upvotes: 10