if div with id has certain text remove other div

css, if-statement, javascript, php

Solution

You Missed the single Quote. It will work great.

<script language="javascript"> 
var text = $('#div_with_dynamic_text').text();
var comparingText = 'THE_TEXT'
if(text == comparingText){
 $('#OTHER_DIV').css('display','none'); 
 }; 
</script>

Problem

if div with id has certain text remove other div. ``` <script language="javascript"> var text = $('#div_with_dynamic_text').text(); var comparingText = 'THE_TEXT' if(text == comparingText){ $('#OTHER_DIV).css('display','none'); }; </script> <div id="div_with_dynamic_text">THE_TEXT</div> <div id="OTHER_DIV"> some other div which needs to hide if certain text</div> ```

Original source