javascript - jquery has() not working as expected -


let's have markup:

<div class="comment">   <span class="test">some content here</span> <p>lorem ipsum</p> </div>  <div class="comment">   <p>lorem ipsum</p> </div> 

i want check if span.test exists within div.comment , if exists hide div.comment , show div.comment in span.test doesn't exist.

i'm stuck here :

 if($("span.test").length) {     $(".element:has(span.test)").hide(); 

i don't know how continue achieve want.

any suggestions on how can make work ?

$("div.comment").filter(function () {     return $(this).find('span.test').length }).hide(); 

jsfiddle example


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -