I want to change this:
<div id="main 1" style="background: #ccc;" class="fourcol first clearfix" role="main">
LEFT
</div>
<div id="main middle" style="background: #ddd;" class="fourcol middle clearfix" role="main">
MENU
</div>
<div id="main 3" style="background: #eee;" class="fourcol last clearfix" role="main">
RIGHT
</div>
to this(order: MENU, LEFT, RIGHT) when I resize the window below 481px, with;
jQuery(document).ready(function($) {
$(window).resize(function() {
var responsive_viewport = $(window).width();
if (responsive_viewport < 481) {
$('#inner-content').parent().prependTo('middle');
}
});
Use this
$(window).resize(function() {
var responsive_viewport = $(window).width();
//console.log(responsive_viewport);
if (responsive_viewport < 481) {
var middle_div = $('#main-middle').clone().remove();
$("#main-1").before(middle_div);
}
});
You div ids have space which is not allowed. I guessing there was either an hyphen or underscore which you have missed out. I have added hyphen in my code.
Also the above code keeps adding the menu when the viewport < 481. So try setting a flag or something once it has already moved. Otherwise you are going to have multiple menus.
Cheers!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With