Bob
Bob

Reputation: 221

Why doesn't this jQuery selector work?

$('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?

Upvotes: 2

Views: 165

Answers (1)

MacAnthony
MacAnthony

Reputation: 4521

: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/

Upvotes: 5

Related Questions