I need to check to make sure that all certain elements that are children of their parent container have a specific class. Can someone tell me how to do this in jQuery?
if all paragraph tags of div tag have the class “correct”
-> yep, all of them have the class
otherwise, not all paragragh tags in div tag have that class
-> noope, they all do not have the required class
If you mean direct children, then:
To include all descendant
<p>tags in the reckoning, use “.find()” instead of “.children()”.edit — it’d be keen to have a plugin for stuff like this:
Then you could write:
A similar “.any()” function would be useful too.