开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜