atljarman
asked on
Window Resize not firing Javascript/Jquery
Hi,
I have a jquery/javascript function that works great if you reload the page. I would like to get this function in an OnReady function, but not sure if that is possible. When reloading, after changing the screen dimension the function fires. However, if you just do a resize of the window it does not. I need it to fire everytime the window is resized.
I have a jquery/javascript function that works great if you reload the page. I would like to get this function in an OnReady function, but not sure if that is possible. When reloading, after changing the screen dimension the function fires. However, if you just do a resize of the window it does not. I need it to fire everytime the window is resized.
<script type="text/javascript">
var eventFired = 0;
if ($(window).width() < 960) {
$(".topItems").hide();
$(".siteBanner").hide();
alert('Less than 960 - mobilized');
} else {
alert('More than 960 - demobilized');
eventFired = 1;
}
$(".topItems").hide();
$(".siteBanner").hide();
alert('Less than 960 resize - mobilized');
} else {
alert('More than 960 resize');
}
}
});
</script>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
? What do you mean it works in the footer but not the header - do you mean where you place the script?
Look where you include your JQuery library - it has to come after that.
Look where you include your JQuery library - it has to come after that.
ASKER
Thank you guys. I got it working.
ASKER