我想顯示按鈕點擊日期選擇器和jQuery中與選定的日期填寫文本顯示日期選擇器的圖標,點擊並填寫文本框,使所選日期
$(function() {
\t //today=new Date(1000*today);
var dateFormat = "mm/dd/yy",
from = $("#from_filter")
.datepicker({
defaultDate: "+0w",
changeMonth: false,
numberOfMonths: 1
})
.on("change", function() {
to.datepicker("option", "minDate", getDate(this));
}),
to = $("#to_filter").datepicker({
defaultDate: "+0w",
changeMonth: false,
numberOfMonths: 1
})
.on("change", function() {
from.datepicker("option", "maxDate", getDate(this));
});
function getDate(element) {
var date;
try {
date = $.datepicker.parseDate(dateFormat, element.value);
} catch(error) {
date = NULL;
}
return date;
}
});
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<div class="col-md-4">
<span>From</span>
<div class="replay-in">
<input type="text" name="" value="" placeholder="04/03/2017" class="form_date" id='from_filter'>
<span class="glyphicon glyphicon-calendar from_icon " style="padding-right: 6px">icon</span>
</div>
</div>
<div class="col-md-4">
<span>To</span>
<div class="replay-in">
<input type="text" name="" value="" placeholder="04/03/2018" class='to_filter' id='to_filter'>
\t \t \t \t \t \t \t <span class="glyphicon glyphicon-calendar to_icon" style="padding-right: 6px">icon</span>
</div>
</div>
我想說明日期選擇器上的圖標點擊。日期選擇器只顯示在文本框上點擊
'我想要'是您的要求。這裏有什麼問題?你是否面臨任何錯誤?你嘗試過哪些調試步驟?請用更多信息更新問題。 –