Link to home
Start Free TrialLog in
Avatar of badwolfff
badwolfffFlag for United Kingdom of Great Britain and Northern Ireland

asked on

How do I user jQuery to hide a parent of a specific element?

I have created a jsfiddle for this:

https://jsfiddle.net/Lqfdhyu4/

If the condition is met, then I need to hide the div.form-group and the h4 the precedes it:
<h4><br>Product Attributes</h4>

thanks
Avatar of hielo
hielo
Flag of Wallis and Futuna image

// hide all the h4 within #product
$('h4','#product').hide();

// hide the first h4 within #product
$('h4:eq(0)','#product').hide();
Avatar of badwolfff

ASKER

Hi,

not working for me. I tried this on jsfiddle as suggested by you

if( ( $('body[class^="product-product-"] #content .form-group select option, body[class^="service-product-"] #content .form-group select option').length ) == 1)
    {
      $('h4','#product').hide();
    }
else{
    alert("not found");
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial