html - How to check class name exist in child div; of parent div using jquery? -
how check whether div class within div class exist or not? in following example; want check whether "showonload" div class exist inside; parent div class "hideunhidepanel"? <div id="lodadiv" hidden="true" class="hideunhidepanel"> <div class="showonload"> </div> <div class="showonload"> </div> <div class="showonload"> </div> </div> <div id="load2div" hidden="true" class="hideunhidepanel"> //nothing exist </div> jquery code: $('.hideunhidepanel').each(function() { alert('yo'); if($(this).children('showonload')) alert('child exist'); }); fiddle: https://jsfiddle.net/5h49x7qe/ update : note -> in fiddle, displaying alert thrice; in actual should show 2 times only; third showhidepanel not have "showonload" class. .children() return jquery ...