jayant rawat
jayant rawat

Reputation: 305

JQuery hide Class if other class is visible

I know this question already have asked before and i also tried the answer and it almost worked for me but there is one issue which i can't able to sort i tried plenty of ways but all in wain. This is the div i want to hide

    <div class="price-box" itemprop="offers" itemscope="" itemtype="http://schema.org/Offer">

       <p class="price"><span class="special-price" style="display: none;">
        <span class="amount">$43.50</span>
        </span>
       </p>
    </div>

when this div is not empty

<div class="single_variation"><span class="price"><span class="amount">$43.50</span></span></div>

This is what i implement

  jQuery(document).ready(function() {

    if( jQuery('.single_variation').is(':empty') ){
        alert('hi');
        jQuery('.price-box').show();
    }

  });

and also

if($('.price').length) {
    $('.price-box').hide();
}

Upvotes: 0

Views: 252

Answers (1)

FLX
FLX

Reputation: 2679

:empty select elements that have no children.

What you need to check is ":visible" :

 $(document).ready(function() {

    if($('.single_variation').is(':visible') ){
      alert('hi');
      $('.special-price').hide();
    }

});

Also I replaced show by hide.

Edit : What is this ?

if($('.category').length){
  $('.filter').hide();
}

There is no class like category or filter in your example. Not useful in your question !

Upvotes: 3

Related Questions