jquery - window.resize not working as reloading the resized window -


here piece of jquery loading href link window resized less 767, working fine, disappear want hide , show want see, click on reload button of browser puts webpage same should not on window width of below 767.

not working refresh resized web page.

$(window).bind('resize', function(e){      width = $(window).width();      if (width < 767){         $("a.collapselistbt").show();         // here         if ($('.content-box-right').hasclass('show')){             $('.content-box-right').removeclass('show');         }      } else{         $("a.collapselistbt").hide();         $('.content-box-right').addclass('show');     }  }); 

please suggest how keep still , not let move setting fixed window width of 767

add javascript

$(document).load(function(e){      width = $(window).width();      if (width < 767){         $("a.collapselistbt").show();         // here         if ($('.content-box-right').hasclass('show')){             $('.content-box-right').removeclass('show');         }      } else{         $("a.collapselistbt").hide();         $('.content-box-right').addclass('show');     }  }); 

your problem function called on window.resize, therefore when load page there nothing job want to. more on use css , media queries that, in opinion far better.


Comments