我使用了 http://trentrichardson.com 中的 timepicker 插件
这里我遇到一个问题,选择日期后,Timepicker 弹出窗口没有关闭。
<asp:TextBox ID="datetimepicker" runat="server" CssClass="datetimepicker" >
</asp:TextBox>
JQuery
$(document).ready(function () {
$('.datetimepicker').datetimepicker({});
});
现在它显示如下:
因此,在选择日期后,我希望它关闭。
最佳答案
遗憾的是,这个插件无法添加简洁的 jQuery 代码来隐藏。
它会是这样的:
$(document).on("click", ".ui-datepicker a", function() {
$(this).closest(".ui-datepicker").hide();
});
但它阻止传播
点击事件并调用其他点击处理程序,因此上面的方法不起作用。
下面的解决方案风格很糟糕,但它有效( http://jsfiddle.net/cL9Fx/1/ ):
$(document).ready(function () {
$('#datetimepicker').datetimepicker({});
$("#datetimepicker").click(function() {
$(".ui-datepicker a").each(function(index, elem) {
$(elem).attr("onclick", "$(this).closest(\".ui-datepicker\").fadeOut(\"fast\");");
});
});
});
关于jquery - 选择日期后时间选择器弹出窗口未关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15849677/