我想通过单击 jQuery UI 日期选择器中的日期来触发事件
我正在开发一个使用 jQuery 日期选择器的网站。它就像一种向导一样工作,首先您选择一项服务,然后选择一个可用日期,然后选择一个可用时间。按照目前的情况,“下一个”按钮会显示日期选择器的日历何时启动,我想将其保持隐藏状态,直到选择日期为止。我添加了一个名为“choose_a_date”的 div,作为我希望它保留到选择日期为止的位置。
jQuery:
<script type='text/javascript'>
$(document).ready(function(){
$('#date_panel,#time_panel,#confirm_panel').hide();
$(".booking").click(function(){
$('#svc_panel').fadeIn(function(){
$('#date_panel,#time_panel,#confirm_panel').hide();
});
});
$(".date_button").click(function(){
$('#svc_panel,#time_panel,#confirm_panel,').hide();
$('#date_panel').fadeIn(function(){
});
});
$('.time_button').click(function(){
$('#svc_panel,#date_panel,#confirm_panel').hide();
$('#time_panel').fadeIn(function(){
});
});
$('.confirm_button').click(function(){
$('#svc_panel,#date_panel,#time_panel').hide();
$('#confirm_panel').fadeIn(function(){
});
});
});
</script>
HTML:
<div id="date_panel">
<p>Choose a date: <input id="datepicker" type="text"></p>
<div id="wait_for_date"><a href="#" class="time_button">Next</a></div>
</div>
<div id="time_panel">
<div>Choose a time on: <span id="target"></span></div>
<table>
<tr>
<td class="confirm_button"><a href="#">11:30 am</a></td>
</tr>
<tr>
<td class="confirm_button"><a href="#">12:30 pm</a></td>
</tr>
<tr>
<td class="confirm_button"><a href="#">2:00 pm</a></td>
</tr>
</table>
</div>
I'm working on a site that uses jQuery datepicker. It works as a kind of wizard, where first you pick a service, then you pick an available date, then you pick an available time. As it stands, the 'next' button shows when datepicker's calendar intiates, and I'd like to keep it hidden until a date is picked. I've included a div called 'choose_a_date' as the point where I'd like it to hold until, well, a date is chosen.
jQuery:
<script type='text/javascript'>
$(document).ready(function(){
$('#date_panel,#time_panel,#confirm_panel').hide();
$(".booking").click(function(){
$('#svc_panel').fadeIn(function(){
$('#date_panel,#time_panel,#confirm_panel').hide();
});
});
$(".date_button").click(function(){
$('#svc_panel,#time_panel,#confirm_panel,').hide();
$('#date_panel').fadeIn(function(){
});
});
$('.time_button').click(function(){
$('#svc_panel,#date_panel,#confirm_panel').hide();
$('#time_panel').fadeIn(function(){
});
});
$('.confirm_button').click(function(){
$('#svc_panel,#date_panel,#time_panel').hide();
$('#confirm_panel').fadeIn(function(){
});
});
});
</script>
HTML:
<div id="date_panel">
<p>Choose a date: <input id="datepicker" type="text"></p>
<div id="wait_for_date"><a href="#" class="time_button">Next</a></div>
</div>
<div id="time_panel">
<div>Choose a time on: <span id="target"></span></div>
<table>
<tr>
<td class="confirm_button"><a href="#">11:30 am</a></td>
</tr>
<tr>
<td class="confirm_button"><a href="#">12:30 pm</a></td>
</tr>
<tr>
<td class="confirm_button"><a href="#">2:00 pm</a></td>
</tr>
</table>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看 onSelect 事件的文档
Check out the documentation for the onSelect event
Datepicker 有
onSelect
,当选择日期时会调用它。Datepicker has
onSelect
which is called when a date is selected.