0

I want to run the called function once every time the page is resized

$(window).on('resize load',function(){
  if( $(this).width() < 768 ){
    $('ul.menu-list').hide();
  }else{
    $('ul.menu-list').show();
  }
});

$('.toggle-btn').click(function () {
  $('ul.menu-list').slideToggle(300);
});
vciloglu
  • 526
  • 2
  • 7
  • 19
  • And what exactly is your question? – hallleron Aug 10 '17 at 08:05
  • Media queries are a better idea: https://stackoverflow.com/questions/15558692/jquery-how-do-i-hide-a-dropdown-menu-only-at-mobile-screen-resolution – mplungjan Aug 10 '17 at 08:06
  • @hallleron When the page is resized. If the width is less than 768px den, the menu it hides. It opens when you press again. If a page is resized and 768px is still small. Menu still hides. i don't want this. – vciloglu Aug 10 '17 at 08:11
  • update question. add toggle menu button. – vciloglu Aug 10 '17 at 08:12

0 Answers0