IE9 not accepting standard jQuery Syntax

假如想象 提交于 2020-01-03 08:09:48

问题


It's really pretty simple. I have the following code.. and it works in every other html5 compatible browser (Safari 5, Chrome 9, FireFox), but in IE9 (RC) I get the following errors.

jquery.min.js

Line: 16 Error: Object doesn't support property or method 'getElementsByTagName'

jquery-ui.min.js

Line: 40 Error: Object doesn't support property or method 'tabs'

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=9" />
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/jquery-ui.min.js"></script>

    <script type="text/javascript">
        $(function () {
            $("#ribbon").tabs();
        });
    </script>
</head>
<body>
    <header>
        <span id="branding"></span>
        <div id="ribbon-navigation">
        <div id="ribbon">
    <ul>
        <li><a href="#ribbon-1">1</a></li>
        <li><a href="#ribbon-2">2</a></li>
        <li><a href="#ribbon-3">3</a></li>
        <li><a href="#ribbon-4">4</a></li>
    </ul>
    <div id="ribbon-1" class="ribbon-strip">
        @Html.Partial("Menus/Ribbons/__H1")
    </div>
    <div id="ribbon-2" class="ribbon-strip">
        @Html.Partial("Menus/Ribbons/__2")
    </div>
    <div id="ribbon-3" class="ribbon-strip">
        @Html.Partial("Menus/Ribbons/__3")
    </div>
    <div id="ribbon-4" class="ribbon-strip">
        @Html.Partial("Menus/Ribbons/__4")
    </div>
</div>
        </div>
    </header>
</body>
</html>

I could understand if my CSS just didn't produce the right styles - but it looks like it's outright ignoring $("#ribbon").tabs(); all together. Any ideas?


回答1:


Further digging yielded more fruitful results... bugs.jquery.com/ticket/8052 - This is apparently a bug in IE, and was fixed in an update of jQuery that came out Yesterday of all times! I had to reference jQuery 1.5.1, and it all worked fine.

Thank you to everyone who jumped in with helpful suggestions. They were all very good ideas, but this time it turned out to simply be a bug with IE9 and nothing more.




回答2:


Try:

$(document).ready(function () {
    $("#ribbon").tabs();
});


来源:https://stackoverflow.com/questions/5120869/ie9-not-accepting-standard-jquery-syntax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!