我如何实现<input type="text">的onchange?用jQuery? [英] How do I implement onchange of <input type="text"> with jQuery?
本文介绍了我如何实现<input type="text">的onchange?用jQuery?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有这个 API.
怎么样?
<select>
has this API. What about <input>
?
推荐答案
您可以使用 .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="text">的onchange?用jQuery?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文