[英]How to handle change or input event of input type=“text” if value is inserted from another element without touching this input
I have a input type="text" and next to that a button which opens up a calendar on click. 我有一个输入type =“ text”,旁边有一个按钮,单击后可打开日历。 When a value is selected in calendar textbox ix populated. 在日历文本框ix中选择一个值时,将进行填充。
I would like to handle on change of textbox to enable other controls. 我想处理文本框的更改以启用其他控件。
change, input etc events are triggered only if use manually enters values in the text box. 仅当使用手动在文本框中输入值时,才会触发更改,输入等事件。 But in my case I am not touching the input textbox. 但就我而言,我没有触摸输入文本框。
Thanks. 谢谢。
Use jquery change event. 使用jQuery更改事件。
$("input").change(function(){
//do something
})
Update: 更新:
As .change
event doesn't get fired when you change value using any javascript method, there is a work around. 由于使用任何javascript方法更改值时不会触发.change
事件,因此可以解决。
When you change the date, you can trigger an event to the input element like $("input").keyup()
and listen using: 更改日期时,可以触发输入元素(例如$("input").keyup()
并使用以下命令进行监听:
$("input").keyup(function(){
// input updated
})
codepen example: https://codepen.io/azharuddinkhan8898/pen/MNrLad codepen示例: https ://codepen.io/azharuddinkhan8898/pen/MNrLad
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.