I have a function to get the tag at the top that contains the
key
specified to it, anywhere in the text.
But I want to have the
Use filter
.
var li = $('.listcontainer ul li').filter(function() { return $(this).text().indexOf(key) === 0; });
Please check filter() in jquery.
Filter
Filter demo as specified in api.jquery
$('li').filter(function(index) {
return $('strong', this).length == 1;
}).css('background-color', 'red');