JS错误“对象预期”仅在IE9上

时间:2012-03-08 04:18:48

标签: javascript jquery

我只在IE9上收到错误,上面写着错误“SCRIPT5007:Object expected”。有2个相同的错误。一个是在 $(文档)开始,另一个标记为“< - error here”

    <script>
        $(document).ready(function(){
            var imagePath = "/sites/all/modules/custom/sixdegrees_right_menu/images/";
            $(".menu-holder").mouseover(function()
            {
                //$(this).children(".menu-title").children(".menu-bg").hide();
                //$(this).children(".menu-title").children(".menu-name").css({"float":"none"});
                //$(this).children(".menu-title").children(".menu-text").css({"float":"none"});

                var imgSrc = $(this).children(".menu-icon").find("img").attr("src");
                imgSrc = imgSrc.replace(imagePath, "");
                imgSrc = imagePath + "h-" + imgSrc;
                $(this).children(".menu-icon").find("img").attr("src", imgSrc);
                <- error here
                //$(this).children(".menu-title").children(".menu-name").children("img").animate({"left": "0px"}, "slow");
                //$(this).children(".menu-title").children(".menu-text").animate({"left": "0px"}, "slow");
            });
        });
    </script>

还有一些注释行,我没有足够的权限删除它,除非我能声称一些东西。

1 个答案:

答案 0 :(得分:2)

在脚本标记中添加一个type =“text / javascript”,并确保在尝试使用jQuery之前成功包含jQuery。