ffffff01
ffffff01

Reputation: 5238

Check if child with specific title exist

I want to check if there is a child with a specific title under my parent., I've managed to check if children exists, but I want to add a check if the title equals the string "No"..

$(this).find('#test').children().size() === 0;

How can this be done?

Upvotes: 3

Views: 2496

Answers (2)

Dunhamzzz
Dunhamzzz

Reputation: 14798

Try this: $('[title="No"]', this);

To explain, this will look for an element with title="No" inside this, which will be your current element in a loop, or can be another selector altogether.

Upvotes: 4

Musa
Musa

Reputation: 97672

Use the attribute equals selector

$(this).find('#test').children('[title=No]').length > 0;

Upvotes: 2

Related Questions