热门关键字:
jquery > jquery教程 > jquery教程 > jQuery判断不同分辨率下的div样式

jQuery判断不同分辨率下的div样式

305
作者:管理员
发布时间:2021/1/20 18:02:00
评论数:0
转载请自觉注明原文:http://www.jq-school.com/Show.aspx?id=3297
<script src="js/jquery-1.8.3.min.js"></script>


<script>


window.onload=function(){


 if (screen.width <= 1024){   //分辨率小于等于1024时


          $(".m1").attr("class", "red");//替换class为ml的样式为red;


$(".m2").show();


       }else{


          $(".m1").show();


  $(".m2").hide();


    }


}


</script>


<style>


.red {color:red;}


</style>


</head>






<body>


<div class="m1">m1m1m1m1mm1m1m1mm11mm1m1m</div>


<div class="m2">m2m2m2m2m2m2m2m2mm2m2m2m2m2m</div>


</body>








如果您觉得本文的内容对您的学习有所帮助:支付鼓励



关键字:ps
友荐云推荐