监控浏览器窗口伸缩(获取窗口宽度)
window.onresize = function () { width = document.body.clientWidth; console.log(width); if (width < 750) { swiperInstance.update({ slidesPerView: 1.253, }); } console.log(swiperInstance); };
获取窗口宽高
const width = window.innerWidth; const height = window.innerHeight;
窗口伸缩时会触发
Jquery 获取浏览器宽度
$(".btnOpenBig").on("click", function () { W = $(window).width(); if (W >= 750) { $(this).parent().parent().toggleClass("picShiftBig"); $(this).parent().next().show(); $(".smallPic").hide(); } });

浙公网安备 33010602011771号