javascript 使用jQuery显示没有特定类的元素的第一个子元素
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8489406/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 03:36:50 来源:igfitidea点击:
Show first child of element without a specific class using jQuery
提问by Tom
I am trying to show the first child of an element which does not have a class of "submitted"
我正在尝试显示没有“已提交”类的元素的第一个子元素
So something like
所以像
$('#menu li:first-child:not(".submitted")').show();
HTML:
HTML:
<ul id="menu">
<li class="submitted">stuff here</li>
<li class="submitted">stuff here</li>
<li>stuff here</li> <!-- This one needs to be shown -->
<li>stuff here</li>
<li>stuff here</li>
</ul>
Any ideas??
有任何想法吗??
回答by Sjoerd
$('#menu li:not(.submitted):first')
回答by Alex Figueiredo
Try this:
试试这个:
$('#menu li:not(".submitted"):first').show();
回答by Sudhir Bastakoti
$('#menu li:first-child').not(".submitted").show();
回答by kvc
yes it does work.You can have look at this example http://jsfiddle.net/gFutw/
是的,它确实有效。你可以看看这个例子http://jsfiddle.net/gFutw/