我希望在单击一个小图像时呈现一个数据报警器,选择日期,使用所选日期填充一组基于所选日期的年份、月份和天数的选择元素。我计算出了onSelect部分,并将所选日期应用到select元素中的选项中。
我的问题是数据报警器没有关闭日期选择。它就呆在那里。如果我调用hide()方法,它也会隐藏图像( span元素的一部分)。这是我的HTML代码:
<span id="pickupCalendar"><img src="/images/calendar.png"></img></span>这是一个脚本:
$("#pickupCalendar").click(function () {
$("#pickupCalendar").datepicker({
dateFormat: 'dd-mm-yy',
onSelect: function (dateText, inst) {
//code to fill the other elements with the selected date goes here
$("#pickupCalendar").datepicker().hide(); //<-- hides the image (span element along with the datepicker)
}
});
});发布于 2013-11-23 14:35:29
我会更改HTML标记,这样就可以更容易地将元素作为目标。
<span id="pickupCalendar"></span><button>Button</button>
$("button").click(function () {
$("#pickupCalendar").show();
$("#pickupCalendar").datepicker({
dateFormat: 'dd-mm-yy',
onSelect: function (dateText, inst) {
//code to fill the other elements with the selected date goes here
$("#pickupCalendar").datepicker().hide();
}
});
});小提琴
发布于 2013-11-23 14:09:02
你能试试这个吗?
$("#pickupCalendar").click(function () {
$("#pickupCalendar").datepicker({
dateFormat: 'dd-mm-yy',
onSelect: function (dateText, inst) {
//code to fill the other elements with the selected date goes here
$("#pickupCalendar").datepicker().hide();
$("#pickupCalendar img").hide();
}
});
});https://stackoverflow.com/questions/20163224
复制相似问题