I'm working on dynamically resizing vertical margins with jQuery and I'm wonder if if how I can resolve a problem that causes the margins to resize only once when the page loads.
/* PAGE SIZE */
$(document).ready(function(){
var WIDTH = $(window).width();
if(WIDTH > 1420){
$("ul#menu-content-1.menu").css("margin-top","59px");
$("div.menu-content-container").css("margin-top","59px")
} else if(WIDTH < 1420) {
$("ul#menu-content-1.menu").css("margin-top","-59px");
$("div.menu-content-container").css("margin-top","-59px");
}
});
This is my existing code. How can I fix this recurring problem so that each time the page loads and the window is resized, the margins will adjust?