$('.Schedule .Full input').each(function(i)
{
var controls = $('.Morning input, .MorningPart input, .Afternoon input, .AfternoonPart input', $(this).parents('.Schedule'));
alert(controls.length + " Conflicting Controls\n"+
$(this).parents('.Schedule').attr('id') + " Parent");
});
当我在 Firefox 中运行此代码时,此函数的第一次执行会产生一个警告框,内容如下:
17 Conflicting Controls
Monday Parent
在 IE 6 或 7 中运行的完全相同的页面会产生一个警告框,内容如下:
45 Conflicting Controls
Monday Parent
Firefox 是对的,只有 17 个冲突控件。 IE 识别的 45 个控件不是“星期一”的后代。如果我将“星期一”指定为 $() 函数的上下文,为什么 IE 会返回它之外的控件?
最佳答案
试一试
var controls = $(this).parents('.Schedule').children('.Morning input, .MorningPart input, .Afternoon input, .AfternoonPart input')
关于javascript - jquery $ 函数在 IE 中返回不同的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/830601/