做web开发的时候会遇到需要监听浏览器窗口大小改变事件,而进行相关操作。这里像大家介绍一下 JQuery浏览器窗口改变事件
$(window).resize(); 动态
<script type=”text/javascript”>
$(window).resize(function() {
var width = $(this).width();
var height = $(this).height();
alert(‘width’+width+’-height’+height);
});
</script>
静态
//静态判断窗口宽度
if ($(window).width()<=992){
console.log($(window).width());
// console.log('设置不可点击');
$("a[data-bs-toggle='collapse']").attr("data-bs-toggle","false");
}else{
$("a[data-bs-toggle='false']").attr("data-bs-toggle","collapse");
}原文地址
https://blog.csdn.net/chenyao1994/article/details/80341035
爱笔记