监控浏览器窗口伸缩(获取窗口宽度)

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();
  }
});

 

posted @ 2022-07-24 23:58  SimoonJia  阅读(90)  评论(0)    收藏  举报