IE8 Jquery Javascript“错误:需要对象”窃听器 [英] IE8 Jquery Javascript "Error: Object required" Bug

查看:90
本文介绍了IE8 Jquery Javascript“错误:需要对象”窃听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当此函数中的switch语句运行时,IE8抛出Error:Object required消息(实际jquery库脚本中的错误,而不是我的javascript文件)。此代码适用于IE6,IE7,FF3和Safari ......任何想法?它是否与交换机中的'$(this)'选择器有关?谢谢!

IE8 throws an "Error: Object required" message (error in the actual jquery library script, not my javascript file) when the switch statement in this function runs. This code works in IE6, IE7, FF3, and Safari... Any ideas? Does it have something to do with the '$(this)' selector in the switch? Thanks!


function totshirts(){
    $('.shirt-totals input').val('0');
    var cxs = 0;
    var cs = 0;
    var cm = 0;
    $.each($('select.size'), function() {
        switch($(this).val()){
            case "cxs":
                cxs ++;
                $('input[name="cxs"]').val(cxs);
                break;
            case "cs":
                cs ++;
                $('input[name="cs"]').val(cs);
                break;
            case "cm":
                cm ++;
                $('input[name="cm"]').val(cm);
                break;
        }
    });
}


推荐答案

我将jQuery库从1.2.6升级到1.3.2这解决了这个问题。没有意识到我有一个旧版本 - oops。

I upgraded the jQuery library from 1.2.6 to 1.3.2 and this solved the problem. Didn't realize I had an old version- oops.

感谢您的帮助!

这篇关于IE8 Jquery Javascript“错误:需要对象”窃听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆