Here is the HTML snippet I am dealing with:
<div id="div_top"></div>
<div id="div_bottom"></div>
When viewing the website on a mobile device or resizing the window, I need div_bottom
to appear before div_top
.
To achieve this, I have implemented the following code:
if(window.innerWidth <= 480){
jQuery(document).ready(function(){
jQuery('#div_bottom').insertBefore('#div_top');
});
jQuery(document).resize(function(){
jQuery('#div_bottom').insertBefore('#div_top');
});
}
The onload function seems to be working fine, but the resize function is not functioning as expected.
Is there a jQuery or CSS solution that can help resolve this issue?