Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide div on certain pages using jQuery

Tags:

html

jquery

I would like to hide a div on more than one but not all pages of a site. The following solution hides it on one page but how can I add two or 3 particular pages?

Original answer here: Hide div based on url

<script language="text/javascript">
$(function(){
      if (window.location.pathname == "mywebsite/Videos.html") {
            $('#navleft').hide();
      } else {
            $('#navleft').show();
      }
 });
</script>
like image 538
Anthony_Z Avatar asked Dec 25 '22 23:12

Anthony_Z


1 Answers

just give an or condition

$(function(){
      if (window.location.pathname == "mywebsite/Videos.html"||window.location.pathname == "url2.html"||window.location.pathname == "url3.html") {
            $('#navleft').hide();
      } else {
            $('#navleft').show();
      }
 });
like image 147
Ankit Chaudhary Avatar answered Jan 14 '23 14:01

Ankit Chaudhary