I\'m using the .resize() function to detect window re-size events, but this detects both height and width changes.
Is there any way to detect ju
you can detect both events and just execute code when it's a width change:
var lastWidth = $(window).width();
$(window).resize(function(){
if($(window).width()!=lastWidth){
//execute code here.
lastWidth = $(window).width();
}
})
And you might want to check event debouncing.
Debouncing enforces that a function not be called again until a certain amount of time has passed without it being called. As in "execute this function only if 100 milliseconds have passed without it being called.
Read more: