2017-10-15 102 views
0

我無法使用輸入type="text"使我的日期選取器工作。任何幫助都會很棒。使用輸入類型=「文本」的jQuery UI日期選擇器

$(document).ready(function() { 
 
    $("#checkin").datepicker(); 
 
    $("#checkout").datepicker(); 
 
});
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.css" rel="stylesheet"/> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script> 
 
<label for="checkin">Checkin</label> 
 
<input type="text" name="checkin" id="checkin" placeholder=" Check in"/> 
 

 
<label for="checkout">Checkout</label> 
 
<input type="text" name="checkout" id="checkout" placeholder=" Check out"/>

+0

什麼錯誤/問題?似乎爲我工作得很好。 –

+0

@PhaniKumarM日期選擇器沒有顯示出來,當我點擊字段。相反,你只是能夠輸入任何東西 – Smith

回答

1

您可以在下面找到使用你的代碼工作樣例。我已經包含了jQuery,jQuery UI JS和CSS文件。

$(function() { 
 
    $("#checkin").datepicker(); 
 
    $("#checkout").datepicker(); 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> 
 
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.css" /> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script> 
 

 
<label for="checkin">Checkin</label> 
 
<input type="text" name="checkin" id="checkin" placeholder=" Check in" /> 
 

 
<label for="checkout">Checkout</label> 
 
<input type="text" name="checkout" id="checkout" placeholder=" Check out" />

+0

非常感謝你,這工作的魅力。只是使用了錯誤的jQuery庫。 – Smith

+0

@CiaraSmith如果解決了您的問題,請接受答案。 :) – cometguy

相關問題