If the window width matches a certain condition, you can use jQuery to trigger an alert. Otherwise, you can execute another block of code using the else statement. Here's an example:

$(window).resize(function() {
  var windowWidth = $(window).width();
  
  if (windowWidth < 768) {
    alert("Window width is less than 768 pixels!");
  } else {
    // Execute other code here if the condition is not met
  }
});

In this example, the resize event is used to continuously monitor the window width. If the width is less than 768 pixels, an alert message will be triggered. Otherwise, you can execute any other code within the else block

if window width jquery alert some ting and else

原文地址: http://www.cveoy.top/t/topic/iofM 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录