jquery input动态绑定onchange事件

来源:互联网 发布:下载app返现金软件 编辑:程序博客网 时间:2024/06/14 21:08

<input type=text>绑定onchange事件的注意事项:

$('input[name=myInput]').change(function() { ... });

However, this event will only fire when the selector has lost focus, so you will need to click somewhere else to have this work.

这个事件只有在当输入框失去焦点时才起作用,你必须通过点击别的地方来触发它。


This is so useful, it is worth putting it in an answer. Currently (v1.8*?) there is no .input() convenience fn in jquery, so the way to do it is

$('input.myTextInput').on('input',function(e){ alert('Changed!')});
这个才是常用 的,jquery挖了个坑


$('elementName').keyup(function() { alert("Key up detected");});
这个方法也可以用


http://stackoverflow.com/questions/1443292/how-to-implement-onchange-of-input-type-text-with-jquery


0 0
原创粉丝点击