javascript - Function inside a function is not working -
i working on responsive design , made function menu change when smaller 540px (meant mobile). change cant click button , guess is because of function inside function.
this part doesn't work:
$('.menuknop').click(function(){ $(".menu").slidetoggle(); });
full code:
checkwidth(){ var windowsize = $(window).width(); if (windowsize < 540) { $(".menu").hide(); $(".menuknop").show(); $('.menuknop').click(function(){ $(".menu").slidetoggle(); }); } else { $(".menuknop").hide(); $(".menu").show(); } } //execute function checkwidth(); $(window).resize(checkwidth);
is want?
$('.menuknop').click(function(){ $(".menu").slidetoggle(); }); function checkwidth(){ var windowsize = $(window).width(); if (windowsize < 540) { $(".menu").hide(); $(".menuknop").show(); } else { $(".menuknop").hide(); $(".menu").show(); } } $(window).resize(checkwidth);
Comments
Post a Comment