【发布时间】:2014-11-14 06:05:23
【问题描述】:
为什么就绪/调整大小事件在 iPad 上不起作用?他们在电脑上工作,但不在 iPad 上。有人知道我做错了什么吗?
jQuery(document).on('ready', function() {
jQuery(window).on('resize', function() {
/* Tablet Portrait size to standard 960 (devices and browsers) */
if (jQuery(window).width() < 960 && jQuery(window).width() > 768) {
//change the attributes from the div #home_content (first parameter: the attribute, what it needs to be)
jQuery('#home_content').attr('class','sixteen columns');
jQuery('#slider').attr('class','sixteen columns');
}
else{
jQuery('#home_content').attr('class','nine columns');
jQuery('#slider').attr('class','nine columns');
}
/* Mobile Landscape Size to Tablet Portrait (devices and browsers) */
if(jQuery(window).width() < 767 && jQuery(window).width() > 480) {
//code
}
else{
}
/* Mobile Landscape Size to Tablet Portrait (devices and browsers) */
if(jQuery(window).width() < 479) {
//code
}
else{
}
}).trigger('resize'); // Trigger resize handlers.
});//ready
【问题讨论】:
-
你的意思是他们没有工作,还是没有解雇?如果您在其中输入
alert('foo'),它会弹出吗? -
在电脑上会弹出,但在 iPad 上不会弹出
-
您是在文档中准备好警报还是调整大小?他们两个都没有开火还是只有一个?
-
你也可以使用 window.addEventListener('orientationchange', function () { // 你的代码在这里 };
-
@brso05,您的编辑将“不”与“事件”匹配(“为什么就绪/调整大小事件不起作用”),这是不正确的。我的编辑是有效的。