/ Published in: jQuery
When building responsive sites, you may find the need to move elements on the page around. Instead of creating multiple instances and toggling them on/off, move the entire divs using jQuery. When the browser width increases again, move it back to the original spot.
Expand |
Embed | Plain Text
// Optimization: Store the references outside the event handler: var $window = $(window); function checkWidth() { var windowsize = $window.width(); if (windowsize < 767) { //if the window is greater than 767px wide move the entire div. $(".awards-row").appendTo(".home-subfeature-row"); } else { //move the div back var awardsRow = document.getElementById('awards-row'); $('.home-featured-row').before(awardsRow); } } // Execute on load checkWidth(); // Bind event listener $(window).resize(checkWidth);
You need to login to post a comment.
