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.
$(document).ready(function() { if( $('.regcurrent:contains("step 1 selection")').length) { $('.newtest').hide(); } });
Comments
Post a Comment