在做网页手机端pc端自适应的时候,我们希望pc端,a模块在前,b模块在后。
当屏幕缩小,换成移动端的时候,我们希望b模块在前,a模块在后。
怎么实现呢,通过jquery实现。
html代码:
上边
下边
jquery代码:
$(window).load(function() {
var sbWidth=$(window).width();
function configIframe(){
sbWidth=$(window).width();
if ( matchMedia( 'only screen and (max-width:767px)' ).matches ) {
$(".content_left").insertAfter($(".content_right"));
}else{
$(".content_left").insertBefore($(".content_right"));
}
}
configIframe();
/*窗口改变事件*/
window.onresize = function () {
/*window.location.reload();*/
configIframe();
}
});