我如何实现<input type="text">的onchange?用jQuery? [英] How do I implement onchange of <input type="text"> with jQuery?

查看:22
本文介绍了我如何实现<input type="text">的onchange?用jQuery?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

怎么样?

<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 事件,例如 keyup, keydownkeypress - 取决于您想要的确切效果.

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.

这篇关于我如何实现&lt;input type="text"&gt;的onchange?用jQuery?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆