I need to hide the div if the page URL contains a specific word. Thanks to this site, I was able to successfully find if the URL contains the word. This code works:
<script type="text/javascript"> if (window.location.href.indexOf("Bar-Ends") != -1) { alert("your url contains bar ends"); } </script>
but for some reason this will not work to hide the div, for example:
<script type="text/javascript"> if (window.location.href.indexOf("Bar-Ends") != -1) { $("#notBarEnds").hide(); } </script> <div id="notBarEnds">this is not bar ends</div>
Does anyone know what is wrong with this code? Any help is appreciated Thanks
source share