2012-01-02 65 views
1

我正在嘗試jquery datepicker,但無法讓它工作。我知道我必須錯過簡單的東西。這裏是我的代碼:jquery - datepicker不工作

HTML:

<div class="demo"> 
    <p>Date: <input type="text" id="datepicker"></p> 
</div><!-- End demo --> 

<div class="demo-description" style="display: none; "> 
    <p>The datepicker is tied to a standard form input field. Focus on the input (click, or use the tab key) to open an interactive calendar in a sma ll overlay. Choose a date, click elsewhere on the page (blur the input), or hit the Esc key to close. If a date is chosen, feedback is shown as t he input's value.</p> 
</div><!-- End demo-description --> 

JS:

$(function() { 
    $("#datepicker").datepicker(); 
}); 

這使得文本字段,但沒有jQuery的日曆。謝謝。

回答

3

日期選擇器是在jQuery UI庫中。您需要包含該選項才能工作。

編輯:您需要包括這一點,

https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js

在你的HTML添加此,

<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" /> 
+0

非常感謝!這工作。剩下的唯一問題就是日曆現在有一個與它下面的字段重疊的清晰背景,使日曆無法讀取。有沒有辦法指定這個背景顏色? – zallarak 2012-01-02 05:42:56

+0

嘗試添加他們的CSS,你應該嘗試jQuery主題選擇器,它有一些很酷的主題。下載你喜歡的一個,並將它們包含在你的html中。鏈接在這裏:http://jqueryui.com/themeroller/ - >在左側窗格中,轉到galary,選擇一個並下載 – 2012-01-02 05:50:09

1

您還沒有加載的日期選擇器jQuery的文件,只是主要的jQuery文件。檢查給here

1

附上datapicker的例子JavaScript文件

<script type="text/javascript" src="scripts/jquery.datePicker.js"></script> 

jquery.datePicker.js