<script>
var w = window.innerWidth; //// we will get the width of the browser
</script>
<div>
for() // for1
my logic
</div>
<div>
for()
my logic
</div>
if the browser size is maximum i want to execute for loop 1.
if the browser size in minimum i want to execute the for loop 2
i tried many ways cant able to fix,
1)wrote a funtion in the script and tried to call the funtion in body tag using onload.
and many ways.
&#13;
如果浏览器大小最大,我想为循环1执行。 如果浏览器大小最小,我想执行for循环2
我尝试过很多方法无法修复,
1)在脚本中编写了一个函数,并尝试使用onload调用body标签中的函数。
答案 0 :(得分:0)
你的问题解释不是很清楚。但是,如果我很好理解,你想要,根据屏幕的宽度执行两个“for”中的一个?
你走了:
var w = window.innerWidth; //you get the width of the windwow
if(w < 500){
for(var i = 0; i < 10; i++){
//do what you want when the width is < than 500
}
else{
for(var i = 0; i < 10; i++){
//do what you want when the width is > than 500
}
}