开发者

Why doesn't this jQuery selector work?

开发者 https://www.devze.com 2023-03-06 21:17 出处:网络
$(\'del, .set-ui-icon-15x41-new:has(:parent+div:has(ins))\').toggle(500); Basically I\'m looking to toggle all del tags, and spans which have the class name of \'set-ui-icon-15x41-new\' that have a p

$('del, .set-ui-icon-15x41-new:has(:parent+div:has(ins))').toggle(500);

Basically I'm looking to toggle all del tags, and spans which have the class name of 'set-ui-icon-15x41-new' that have a parent which contains开发者_如何转开发 a child div that has an ins tag.

To simplify; this doesn't work either:

$('.set-ui-icon-15x41-new:parent')

But this does...

$('.set-ui-icon-15x41-new').parent()

So how can I get the :parent selector to work?


:parent will select elements that are parents, not the parent of the element.

Possible solution:

$(':has(ins) > .set-ui-icon-15x41-new')

Demo:

http://jsfiddle.net/bq4Au/

Updated demo after comments:

http://jsfiddle.net/bq4Au/5/

0

精彩评论

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