Remove css attribute based on screen size/viewport with jQuery

[javascript]
jQuery(document).ready(function() {
// This will fire when document is ready:
jQuery(window).resize(function() {
// This will fire each time the window is resized:
if(jQuery(window).width() >= 800) {
// if larger or equal
var colHeight = Math.max(
jQuery(‘#main’).height(),
jQuery(‘#left’).height(),
jQuery(‘#right’).height()
);
jQuery(‘#main, #left, #right’).height(colHeight);
} else {
// if smaller
jQuery(‘#main, #left, #right’).removeAttr( ‘style’ );
}
}).resize(); // This will simulate a resize to trigger the initial run.
});
[/javascript]

Leave a Reply