Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery each()不在IE 7中工作_Javascript_Jquery_Html_Internet Explorer 7_Each - Fatal编程技术网

Javascript jQuery each()不在IE 7中工作

Javascript jQuery each()不在IE 7中工作,javascript,jquery,html,internet-explorer-7,each,Javascript,Jquery,Html,Internet Explorer 7,Each,我有以下功能可以在Chrome和Firefox中正常工作,但在IE7中无法正常工作。 该函数应该在所选表中的每一行实例上运行。在IE7中,它只运行一次 function rowTotalit(targee) { var sum = 0; var thisRow = targee.closest('tr'); thisRow.find('td.tmipt input').each(function() { var numChk = $(this).val()

我有以下功能可以在Chrome和Firefox中正常工作,但在IE7中无法正常工作。 该函数应该在所选表中的每一行实例上运行。在IE7中,它只运行一次

function rowTotalit(targee) {
    var sum = 0;
    var thisRow = targee.closest('tr');
    thisRow.find('td.tmipt input').each(function() {
        var numChk = $(this).val();
        sum = sum + Number(numChk);
        thisRow.find('.total').fadeOut(200, function() {
            $(this).html(sum);
            $(this).fadeIn(500);
            $(this).val(sum);
        });
        thisRow.find('.total').next().val(sum);
    });
}​
以下是另一个函数中的触发器:

for (trs = 1; trs <= tblerows; trs++) {
    $("#testingmsg").append("ARGH!!" + trs);
    rowTotalit($("#timeChart tr:nth-child(" + trs + ")"));
}​

for(trs=1;trs您的表行
是否被切换(显示/隐藏)

IE处理这个问题的方式与其他浏览器不同,您可能希望使用类似Chrome(F12)中的DOM检查器来调查这是否是您的问题


这是关于IE漏洞的,尽管有很多可用的。

明白了!!

each()中还有另一个find()语句,它过早地终止了each

thisRow.find('.total').fadeOut(200, function() {
            $(this).html(sum);
            $(this).fadeIn(500);
            $(this).val(sum);
        });
        thisRow.find('.total').next().val(sum);
我只是将上面的代码从每个语句中移出,它工作正常

对于那些可能因为IE没有正确运行你的.each()而遭受同样问题的人,下面是我如何调试我的问题的

if($.browser.msie){
alert(someTestValue);
}
我使用上面的条件来测试我的代码的不同部分,这不仅有助于缩小错误的范围,而且我能够保持我的FF&Chrome工作代码的灵活性

我的最终解决方案是实际使用browser if语句为IE和FF&Chrome运行不同的函数


感谢那些提供您帮助的人。希望这能帮助其他人。

如果我理解您的描述,看起来
each()
工作正常,但是您的
for
循环只运行一次。您如何获得
tblerows
?@Sparky672-不完全正确。for循环结束是因为函数“rowtottalit”未完成。为了找到答案,我在each()语句正上方的函数中添加了另一个append(),并将其显示在输出中。我认为添加HTML可能有助于找出问题所在。@bažmegakapa-tblerows是在for循环上方定义的。我没有将其包含在代码段中。
var tblerows=($(“#时间图表tr')。长度-2);
thisRow.find('.total').fadeOut(200, function() {
            $(this).html(sum);
            $(this).fadeIn(500);
            $(this).val(sum);
        });
        thisRow.find('.total').next().val(sum);
if($.browser.msie){
alert(someTestValue);
}