Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if child with specific title exist

Tags:

jquery

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?

like image 238
ffffff01 Avatar asked Jan 01 '26 03:01

ffffff01


2 Answers

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.

like image 103
Dunhamzzz Avatar answered Jan 02 '26 15:01

Dunhamzzz


Use the attribute equals selector

$(this).find('#test').children('[title=No]').length > 0;
like image 40
Musa Avatar answered Jan 02 '26 15:01

Musa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!