我有一个奇怪的问题。我正在使用Parallels在Windows 7上测试IE 9中的一个网站。
我的设置是jQuery 2.1.1,Bootstrap 3.2。
我正在用香菜验证一个表单,如果它在Chrome中运行得很好,但在IE中什么也做不了。当进一步测试时,我意识到DOM甚至根本没有更新。所以我把它剥离成这样来看看到底发生了什么:
$(document).ready(function()
{
console.log('ready')
/*
The form submit handler
*/
$('.submit').click(function(){
fields = $('#promo-form').find(':input');
console.log($(fields).length)
});
});
Chrome Console:
ready
15
IE 9 Console (with F12 Developer Tools)
LOG: ready
LOG: 0
我可以让IE识别一些简单的选择器,比如$('input'),$('form'),但是不能使用jQuery方法来查找集合。在Mac上的Chrome上,一切都运行得很好。
这里有什么想法吗?谢谢你,Rich
发布于 2014-10-08 02:12:26
你试过了吗:http://jsfiddle.net/dhyjwg4L/
刚刚在IE10/ 11中测试过,手头没有IE9机器。
$(document).ready(function () {
alert($("#promo-form :input").length);
});
如果你不想要文本/按钮,去掉输入前的:,它们就不会被计算在内。
$('#promo-form').find(':input');
//Combine the selector to make
$("#promo-form :input")
更新:现在已经在IE 8-11上测试了这一点,并正在对所有这些进行工作。
https://stackoverflow.com/questions/26241876
复制相似问题