【问题标题】:jQuery UI working in Firefox, but not in Chrome & Safari?jQuery UI 在 Firefox 中工作,但在 Chrome 和 Safari 中不工作?
【发布时间】:2010-08-16 01:10:25
【问题描述】:

我正在使用 jQuery UI,特别是 Datepicker 和 Autocomplete,如下:

<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
$("#note_date").datepicker({ 
    maxDate: 0,
});

$("#note_name").autocomplete({
    source: ["1", "2"],
    select: function(event, ui) {
    }
});

它们在 Firefox 3.6.8 中运行良好,但在 Google Chrome 5.0.375.126 和 Safari 5.0 (6533.16) 中根本无法运行。我认为 jQuery UI 的东西应该在这些浏览器中工作?是什么导致他们无法工作?感谢阅读。

【问题讨论】:

    标签: jquery jquery-ui browser google-chrome cross-browser


    【解决方案1】:

    确保您也有 jquery-min.js 脚本。如果您在 Chrome 中右键单击您的页面并选择检查器,您将看到正在发生的错误。以下应该可以工作(我所做的只是添加 jquery-min.js 并在添加 DOM 后让 javascript 最后加载)

    <html>
    <head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
    </head>
    <body>
    <div id="note_date"></div>
    <div id="note_name"></div>
    <script>
    $("#note_date").datepicker({ 
        maxDate: 0,
    });
    
    $("#note_name").autocomplete({
        source: ["1", "2"],
        select: function(event, ui) {
        }
    });
    </script>
    </body>
    </html>
    

    【讨论】:

      【解决方案2】:

      我使用这两种方法,它们适用于所有现代浏览器。

      请注意,您的 datepicker 方法中有一个逗号,应该是

      $("#note_date").datepicker({ 
          maxDate: 0 // no trailing comma
      });
      

      看到它工作here

      至于自动完成,我的设置看起来不错。你在使用任何其他的 JS 框架吗?如果您有实时页面,我可能会提供更多帮助。

      M

      【讨论】:

        【解决方案3】:

        使用

        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js">
        </script> 
        

        而不是

        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js">
        </script>
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-06-07
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-03-03
          相关资源
          最近更新 更多