jquery - Matching element that does not have specific element -


i need run through html blocks .myem class , remove class first div in element if .myem doe not have <p> tags.

this came with, still not remove class. missing?

$('.myem').each(function() {     $(this).not(':has(p)').find('.row:first-child').removeclass('myclass'); }); 

you can in once sweep; many of jquery methods use .each() internally:

$('.myem:not(:has(p)) .row:first-child').removeclass('myclass'); 

Comments

Popular posts from this blog

symfony - InvalidConfigurationException in SecurityExtension.php line 429: No authentication listener registered for firewall "secured_area" -

angular ui router - 10 digest iterations reached in angularjs when using $state.go -

javascript - Handling constructor related functions while testing with mocha and sinon -