gpt4 book ai didi

javascript - jquery $ 函数在 IE 中返回不同的结果

转载 作者:行者123 更新时间:2023-11-30 13:43:37 25 4
gpt4 key购买 nike

$('.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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com