开发者

select object where first child id is not a certain value

开发者 https://www.devze.com 2023-03-20 21:06 出处:网络
ok guyz, g开发者_如何学JAVAot one more question for you. i need to select only the first div ( where first child != \'you\' )

ok guyz, g开发者_如何学JAVAot one more question for you. i need to select only the first div ( where first child != 'you' ) how can i acheive that?

HTML

<div class="test">
    <div id="me"><img src=""></div>
</div>
<div class="test">
    <div id="you"></div>
</div>

what i mean is something like:

$('#test:first-child[id] != value');

well , that is what i need in theory, since i dont think the above line will work.


var yourElement = $(".test").not(":has(>#you:first-child)");
var allImages = yourElement.find("img");

translation: select an element which has class "test" and doesn't have a direct child (">") with the id of "you" which is the first element!

jsFiddle link: http://jsfiddle.net/y3RPD/3/

0

精彩评论

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