最近几天我一直在努力让这件事发挥作用。有两个日期选择器,很像开始和结束日期演示,但不能让它们工作。此代码适用于页面正文,但不适用于我想要搜索栏的标题。
<script type="text/javascript">
$(function() {
$( "#from" ).datepicker({
dateFormat: "dd-mm-yy",
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
onClose: function( selectedDate ) {
$( "#to" ).datepicker( "option", "minDate", selectedDate );
}
});
$( "#to" ).datepicker({
dateFormat: "dd-mm-yy",
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
onClose: function( selectedDate ) {
$( "#from" ).datepicker( "option", "maxDate", selectedDate );
}
});
});
</script>
<form method="post" name="top_search_form" action="<?php bloginfo('wpurl');?>/?page_id=13" style="z-index:inherit">
<input type="hidden" name="a" value="dosearch"/>
<input id="top_search_input" placeholder="Procurar..." style="z-index:inherit" type="text" name="keywordphrase" value=""/>
<input type="text" id="from" name="searchstartdate" placeholder="Partida" class="from" style="z-index:inherit"/>
<input type="text" id="to" name="searchenddate" placeholder="Chegada" class="to" style="z-index:inherit"/>
<input id="top_search_button" type="submit" value="Search" style="z-index:inherit">
</form>
任何人都可以帮助我吗?