javascript - How to select a DIV if its child has any children? -
i'm trying select divs on page if child of theirs has children of own.
here's how structure looks:
<div id="id-some_long_id"> <div class="gk"> <div id="some_longid_#1434646398866197"></div> </div> </div> so want select divs id id-some_long_id if gk div has children. may or may not.
id- stays same , some_long_id changes each one.
the other 1 some_long_id same on parent, , after # it's 16 digit number random.
would using regex idea them or maybe using jquery's .children() $( ".gk" ).children()?
thank you!
$('#id-some_long_id:has(.gk:not(:empty))') however, note, :empty fail if want real children without text nodes. in case can do
$('.gk').filter(function() { return $(this).children().length > 0; });
Comments
Post a Comment