javascript - Hide class if another span's child class is visible using jQuery -


it's similar this topic not working.

here codes:

<span class="main_price">    $50 </span>  <span class="option_price">    <span class="option_price_value">       $70    </span> </span> 

by default "main_price" , "option_price" class visible , "option_price_value" class visible has options.

now i'm trying hide "main_price" when "option_price_value" visible.

for more clear, when has no options default it's showing

<span class="main_price">        $50     </span>      <span class="option_price">     </span> 

and when options available should like

<span class="main_price" style="display:none;">        $50     </span>      <span class="option_price">        <span class="option_price_value">           $70        </span>     </span> 

edited include jquery, fiddle working now. check new version out: https://jsfiddle.net/cbbs2oms/3/

basically checking if there's text in option span , showing main price if there's not option value. let me know if i've misunderstood.

$(".option_price_value").each(function(){     if ($(this).text().trim().length) {         $('.main_price').hide();          console.log('has option');     } else {          $('.main_price').show();           console.log('has no option');     } }); 

Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -