1

我需要在我的项目中实现 jQuery 日期选择器。这是我的脚本:

<script type="text/javascript">
    $(document).ready(function () {
        $("#datepicker").datepicker();
    });
</script>

我在我的 HTML 中添加了这些链接:

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>

<label style="padding-left: 5px;">Date</label><input type="text" id="datepicker" />

但是我无法使用该代码显示下拉窗口。我怎么解决这个问题?当我查看页面的视图源时,该函数有一些额外的 jquery 脚本,例如:

    <link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
    <link href="../../Content/themes/base/jquery-ui-1.9.2.css" rel="stylesheet" type="text/css" />
    <link href="/Scripts/jtable/themes/standard/jtable_empty.css" rel="stylesheet" type="text/css" />
    <link href="../../Content/application.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.8.3.js" type="text/javascript"></script>
    <script src="/Scripts/jquery.unobtrusive-ajax.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-ui-1.9.2.js" type="text/javascript"></script>
    <script src="/Scripts/jtable/jquery.jtable.js" type="text/javascript"></script>
    <script src="../../Scripts/knockout-2.1.0.js" type="text/javascript"></script>
    <link href="/Scripts/jtable/themes/standard/jtable_empty.css" rel="stylesheet" type="text/css" />
    <link href="/Content/themes/base/jquery-ui-1.9.2.css" rel="stylesheet" type="text/css" />
    <script src="/Scripts/jtable/jquery.jtable.js" type="text/javascript"></script>
    <script src="/Scripts/jquery.cookie.js" type="text/javascript"></script>
    <script src="/Scripts/modernizr-1.7.min.js" type="text/javascript"></script>
    <script src="/Scripts/knockout-2.2.0.js" type="text/javascript"></script>
    <script src="/Scripts/advancedSearch/AdvancedSearch.js" type="text/javascript"></script>
    <script src="/Scripts/advancedSearch/jquery.validationEngine.js" type="text/javascript"></script>
    <script src="/Scripts/advancedSearch/jquery.validationEngine-en.js" type="text/javascript"></script>
    <link href="/Scripts/advancedSearch/validationEngine.jquery.css" rel="stylesheet" type="text/css" />
4

2 回答 2

2

尽量使用noConflict()以避免冲突。

例子:

<script type="text/javascript" src="other_lib.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
  $.noConflict();
  // Code that uses other library's $ can follow here.
</script>

看这里

于 2013-03-25T10:42:34.737 回答
1

你可以做以下

先调用你的 jQuery 相关脚本

<script type="text/jscript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script type="text/jscript" src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>

然后

var jQueryVariable = jQuery.noConflict(true);

现在使用 jQueryVariable 调用任何你想调用 jQuery 的日期选择器

于 2013-03-25T10:44:47.503 回答