簡體   English   中英

jQuery在IE 9或更舊版本中不起作用

[英]Jquery not working in IE 9 or older

原諒我不是最好的JQuery程序員,但遇到了一個問題。 我的Jquery在FF / IE10中完美運行,僅此而已。 我不確定為什么,但是這是我的代碼。 如果可以的話請幫忙!

文本框“ custom-url”也不會隱藏在加載中,當下拉列表更改為選項“ custom”時也不會隱藏在.show中,就像在其他瀏覽器中一樣。

我目前正在使用jquery-1.5.1,這是我的文本框的html:

<input type="text" id="custom-url" style="width:220px;"/>

下一部分僅特定於當前頁面,因此將其導入到使用它的頁面中。

<script type="text/javascript">

    $(document).ready(function () {
        "use strict";
        $("#custom-url").hide();
    });

    $("select#url-list").change(function () {
        "use strict";
        var selectedItem = $("option:selected", $(this)),
        selectedValue = selectedItem.val();
        $("#url").val(selectedValue);
        if (selectedValue === "custom") {
            $("#custom-url").show();
        } else {
            $("#custom-url").hide();
        }
    });

    $("form").submit(function () {
        "use strict";
        var selectedItem = $("select#url-list option:selected"));
        var selectedvalue = selectedItem.val();
        if (selectedvalue === "custom") {
            $("#Url").val($("#custom-url").val());
        } else if (selectedvalue === '') {
        } else {
            $("#Url").val(selectedItem.val());
        }
    });

</script>

下一部分是全局特定的,因此將其導入主數據庫。

<script src="@Url.Content("~/Scripts/MyScripts.js")" type="text/javascript"></script>

   $(document).ready(function () {
         var str = $('iframe').attr('src');
         var substr;
         var current_tab = "";

         $("#topNav ul:first-of-type li:last-child").hover(function () {
             $(this).addClass("elementHovered");

         }, function () {
             $(this).removeClass("elementHovered");
         });


         if (str == undefined) {
            // alert($("ul:first-of-type li:last-child").parent().html());

              current_tab = "Admin";

              $("#topNav ul:first-of-type li:last-child").children().addClass("elementHovered");             

         }
         else {


             substr = str.split('/');
             var str = "";
             var i;
             for (i = 0; i < substr.length; ++i) {
                 str = str + "subtri[" + i.toString() + "]" + substr[i] + "         ";
             }



             $('#topNav ul:first-of-type').children('li').each(function () {
                 if (substr[2] == "prototype.sunoconet2012.com") {
                     current_tab = "Documents";
                 }
                 else if (substr[3] == "admin") {
                     current_tab = "Home"
                 }
                 else {
                     switch (substr[1]) {

                         case 'contracts':
                             current_tab = "Account Information"
                             break;
                         case 'financials':
                             current_tab = "Financial"
                             break;
                         case 'pricing':
                             current_tab = "Pricing"
                             break;
                         case 'operations':
                             current_tab = "Operations";
                             break;
                         case 'support':
                             current_tab = "Support"
                             break;
                         case 'admin':
                             current_tab = "Support"
                             break;
                         case 'SunocoUniversity':
                             current_tab = "Training";
                             break;
                         case 'onlinetraining':
                             current_tab = "Training";
                             break;
                         default:
                             current_tab = "Administration";
                             break;
                     }
                 }

                 if (current_tab == $(this).text()) {
                    // alert("current_tab:  " + current_tab + "    this.text:  " + $(this).text());
                     //    alert("substr[1]      = " + substr[1] + "substr[2]      = " + substr[2] + " substr[3]      = '" + substr[3] + "'  current_tab    = " + current_tab + "  $(this).text() = " + $(this).text()); // "this" is the current element in the loop
                     $(this).children().css("background-color", "#4D77A7");
                     $(this).children().css("color", "white");
                 }
             });
         }

     });

更新到Jquery 1.9.1可以解決問題!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM