input输入框的change事件,要在input失去焦点的时候才会触发
1
|
$(
'input[name=myInput]'
).change(
function
() { ... });
|
在输入框内容变化的时候不会触发change,当鼠标在其他地方点一下才会触发
用下面的方法会生效,input
1
2
3
|
$(
"#input_id"
).on(
'input'
,
function
(e){
alert(
'Changed!'
)
});
|
注释:
当元素的值发生改变时,会发生 change 事件。
该事件仅适用于文本域(text field),以及 textarea 和 select 元素。
change() 函数触发 change 事件,或规定当发生 change 事件时运行的函数。
**当用于 select 元素时,change 事件会在选择某个选项时发生。当用于 text field 或 text area 时,该事件会在元素失去焦点时发生。