if window width jquery alert some ting and else in document ready
If the window width is less than a certain value, we can use jQuery to display an alert message. Otherwise, we can use the document ready event to execute some code.
Here's an example:
$(document).ready(function() {
if ($(window).width() < 768) {
alert("Window width is less than 768 pixels");
} else {
// Execute some code here
}
});
In this example, if the window width is less than 768 pixels, an alert message will be displayed. Otherwise, the code inside the else block will be executed when the document is ready. You can replace the "// Execute some code here" comment with the specific code you want to run
原文地址: http://www.cveoy.top/t/topic/iofO 著作权归作者所有。请勿转载和采集!