I'm trying to rewrite this as a for loop; my attempt below failed. Any ideas?
jQuery.event.add(window, "load", resizeFrame);
jQuery.event.add(window, "resize", resizeFrame);
function resizeFrame()
if ($(window).width() < 232){
$("#grid-content").css( 'width', '232px' );
}else if ($(window).width() < 458){
$("#grid-content").css( 'width', '232px' );
}else if ($(window).width() < 684){
$("#grid-content").css( 'width', '458px' );
}else if ($(window).width() < 910){
$("#grid-content").css( 'width', '684px' );
}else if ($(window).width() < 1136){
$("#grid-content").css( 'width', '910px' );
};
};
The result is the div (#grid-content) is really wide around 3000px, regardless of window size.
jQuery.event.add(window, "load", resizeFrame);
jQuery.event.add(window, "resize", resizeFrame);
function resizeFrame()
for (var x=232;x<=3000;x=x+226){
if ($(window).width() < x ){
$("#grid-content").css( 'width', x +'px' );
};
};
};
{fromfunction resizeFrame()a typo in your question?varfor declaringxinside your for loop or it will become a global variable otherwise.