我正在尝试在我的网页宽度介于700px和800px之间并且高度介于400px和500px之间时执行我的功能。
这是我的功能:
$(document).ready(function() {
function checkWidth() {
var windowWidth = $(window).width();
var windowHeight = $(window).height();
if (windowWidth >= 700 && windowWidth <= 800 && windowHeight >= 400 && windowHeight >=500 ) {
$('#text')
.keyboard({ layout: 'qwerty' })
.autocomplete({
source: availableTags
})
.addTyping();}
}
}
// Execute on load
checkWidth();
// Bind event listener
$(window).resize(checkWidth);
该函数有效但在if语句中不会执行。