javascript - 仅在 IE9 上出现 JS 错误 "Object expected"

标签 javascript jquery

我只在 IE9 上收到错误消息“SCRIPT5007:预期对象”。有2个相同的错误。一个在开始时位于 $(document),另一个标记为“<- 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>

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

最佳答案

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

关于javascript - 仅在 IE9 上出现 JS 错误 "Object expected",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9612822/

相关文章:

IE 中的 jQuery ajax 调用 - 编码

javascript - javascript 中过度 for() 循环的替代方案

javascript - Phonegap 阻止 pageinit

javascript - react : Why is it necessary to have immutable props if values are passed as by value anyway?

javascript - 在不使用嵌套 for 循环的情况下迭代 JavaScript 数组

javascript - 简单的 jQuery "push"菜单 - 偏移主容器和菜单但转换时间不正确

javascript - SimpleCartJS : Add CSS classes to generated cart table - displaying a custom cart

javascript - 使用Jquery从表格单元格获取复选框的值

php - 如何在 jQuery 的同一窗口中加载 PHP 页面

javascript - 如何使用 React 从 API 调用中呈现多个项目