How to find a List item by using its id
How to find a List item by using its id..i tried like below...But it is 开发者_如何学Pythonnot works for me...
$("#tabs li").find("#" + tabName+"1").addClass("current");
Please help me...
Check this
<ul>
<li>foo</li>
<li>bar</li>
</ul>
We can select the list items and iterate across them:
$('li').each(function(index) {
alert(index + ': ' + $(this).text());
});
$("#" + tabName+"1").addClass("current");
? :)
$('li').each(function() {
var checkID = $(this).attr("id");
//now if you find the id your are searching for
if(checkID=="searchedID")
{
$(this).addClass('yourClass');
}
});
精彩评论