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

JS Error "Object expected" only on IE9

本文关键字:仅在 IE9 对象 错误 JS      更新时间:2023-09-26

我只在IE9上得到一个错误,错误显示"SCRIPT5007:预期对象"。有两个相同的错误。一个在开始时位于$(文档),另一个标记为"此处<-error"

    <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>

还有一些评论行,我没有足够的权限删除它,除非我可以索赔。

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