我正在用jquery在html窗體中創建Date拾取器。以下是我的代碼:jquery衝突問題
HTML頭中代碼:
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/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.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function() {
$("#datepicker").datepicker({ minDate: -0, maxDate: "+12M +10D" });
});
</script>
<script>
$(function() {
$("#datepicker2").datepicker({ minDate: -0, maxDate: "+1M +10D" });
});
</script>
HTML正文部分代碼:
<p>Date From: <input type="text" id="datepicker" ></p>
<p>Date To: <input type="text" id="datepicker2" /></p>
好,形式做工精細但我已經另一個Jquery標籤到我網站的頁腳,代碼如下:(只給jQuery代碼)
<script src="jquery/jquery.js" type="text/javascript" charset="utf-8"></script>
<script src="jquery/jquery.tabify.js" type="text/javascript" charset="utf-
8"></script>
<script type="text/javascript">
// <![CDATA[
$(document).ready(function() {
$('#menu3').tabify();
$('#menu2').tabify();
});
// ]]>
</script>
問:當我添加此頁腳代碼,然後日期選取器無法正常工作。如果我刪除頁腳代碼,那麼它工作正常。爲什麼?它有衝突嗎?
你打開控制檯,並檢查錯誤? – adeneo
你包含jQuery兩次:x – billyonecan
@adeneo,我是這方面的新人。我不知道什麼是控制檯,你能告訴我嗎? –