我如何实现< input type =“文本">的onchange操作.用jQuery? [英] How do I implement onchange of <input type="text"> with jQuery?
本文介绍了我如何实现< input type =“文本">的onchange操作.用jQuery?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<select>
具有此API.那<input>
呢?
<select>
has this API. What about <input>
?
推荐答案
您可以使用 .change()
You can use .change()
$('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.
如果这不太适合您,则可以使用其他一些 jQuery事件,例如关键字,键按下-取决于您想要的确切效果.
If that's not quite right for you, you could use some of the other jQuery events like keyup, keydown or keypress - depending on the exact effect you want.
这篇关于我如何实现< input type =“文本">的onchange操作.用jQuery?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文