jQuery 事件 - resize() 方法

对浏览器窗口调整大小进行计数:

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>菜鸟教程(runoob.com)</title>

<script src="https://cdn.bootcss.com/jquery/1.10.2/jquery.min.js">

</script>

<script>

x=0;

$(document).ready(function(){

$(window).resize(function(){

$("span").text(x+=1);

});

});

</script>

</head>

<body>

<p>窗口重置了 <span>0</span> 次大小。</p>

<p>尝试重置窗口大小。</p>

</body>

</html>

猜你喜欢

转载自blog.csdn.net/qq_31065757/article/details/82820426