I am using Bootstrap's grid to organize the layout of a webpage. Between lg and sm sizes, the webpage looks like this:
|col-1|col-2|
When the size of the window is in the xs range, the columns stack like this:
|col-1|
|col-2|
Instead, I want it to stack like this:
|col-2|
|col-1|
To do this, I created a function to switch the inner HTMLs of the div tags. It works some of the time, but occasionally col-1 is still above col-2.
function mobileHandler() {
var width=window.innerWidth;
if (width<768) {
var col1=document.getElementById('col1').innerHTML;
var col2=document.getElementById('col2').innerHTML;
document.getElementById('col1').innerHTML=col2;
document.getElementById('col2').innerHTML=col1;
}
}
window.onload=mobileHandler;
window.onresize=mobileHandler;
Is there a bug anyone can spot with my code? Or is there a better way to accomplish what I want?