This question already has an answer here:
这个问题在这里已有答案:
- jQuery Datepicker onchange event issue 14 answers
jQuery Datepicker onchange事件发布14个答案
I have a Jquery UI inline Datepicker widget with an id of '19', set with an altField of '#desc19'.
我有一个ID为“19”的Jquery UI内联Datepicker小部件,使用altField为“#desc19”设置。
The HTML is a simple
HTML很简单
<div class="datepicker" id="19"></div>
<input type="text" id="desc19">
This works fine. I click a date on the calendar, and the text field updates.
这很好用。我单击日历上的日期,文本字段更新。
However, I've also got a script that tries to run whenever the date in the text field is updated.
但是,我还有一个脚本,只要文本字段中的日期更新,它就会尝试运行。
$("#desc19").on("input", function(){
alert("???");
});
And this does... Nothing. I click a date on the calendar, and the alert does not display. I change the field manually, and the alert does not display. I cannot for the life of me figure out why. Putting the alert outside of the function works fine, but of course that defeats the point.
这确实......没什么。我单击日历上的日期,并且不显示警报。我手动更改字段,并且不显示警报。我不能为我的生活找出原因。将警报置于功能之外可以正常工作,但当然这会失败。
1 个解决方案
#1
2
Use the .change()
event instead, and see if that works. If not, use the datepicker and an .onblur
for clicking off it (or hiding it by selecting a date)
请改用.change()事件,看看是否有效。如果没有,请使用datepicker和.onblur单击它(或通过选择日期隐藏它)
#1
2
Use the .change()
event instead, and see if that works. If not, use the datepicker and an .onblur
for clicking off it (or hiding it by selecting a date)
请改用.change()事件,看看是否有效。如果没有,请使用datepicker和.onblur单击它(或通过选择日期隐藏它)