jquery - Hide a class if the text in another class contains . . . -


i working form has multiple steps, hide span of text has class .newtest applied if class, .regcurrent contains text "step 1 selection".

<ol class="steps"> <li class="regcurrent">step 1 selection</li> <li class="notcurrent">step 2 selection</li> <li class="notcurrent">step 3 selection</li> </ol>  <div class="singlecol"> <span class="newtest"> <h1>some text</h1> <p>some more text</p> </span> <p>some text , tables</p> </div> 

what have tried:

<script> $(document).ready(function() { if( $('.regcurrent:contains("step 1 selection")') { $('.newtest').hide(); } }); </script> 

you have use length selector in condition, other wise wont false jquery object event when selector not return object. missed closing parenthesis of in condition.

live demo

$(document).ready(function() {   if( $('.regcurrent:contains("step 1 selection")').length) {     $('.newtest').hide();   } }); 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -