Finding all LIs that have name="checked"
I'm trying to find all LIs with name=checked and hide() them, but this开发者_运维技巧 doesn't seem to be working:
$('li').attr("name","checked").hide();
<li name="unchecked" style="display: inline;"><a href="/">Home</a></li>
Any ideas?
This should do it:
$('li[name="checked"]').hide();
Doing:
$('li').attr("name","checked").hide();
will change the name of all lis
to checked and then hide them, so it is wrong...
and another one (choose any version of a query)
$('li').filter('[name=checked]').hide();
just to add to the correct answers above, your usage is to set the value of the attribute specified in the first argument to the value specified in the second.
精彩评论