jQuery更改直到模糊才会触发 [英] JQuery change not firing until blur

查看:87
本文介绍了jQuery更改直到模糊才会触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用change(handler)来侦听文本区域的更改事件,但是我仅在文本区域失去焦点时才接收事件,但是我想在值更改时立即接收事件.

I use change(handler) to listen to change events to a textarea, but I only receive an event when the textarea loses focus, but I want to receive an event as soon as the value changes.

$("#text_object").change(listener);
function listener(dom){
alert("I'm not getting here before the textarea loses focus");
}

推荐答案

不幸的是,浏览器仅在字段模糊时才识别出更改,因此您可能希望尝试附加keyup侦听器.不幸的是,这不是最优雅的解决方案.

Unfortunately the browser only recognises a change when the field blurs, so you might want to try attaching a keyup listener. Not the most elegant solution, unfortunately.

http://api.jquery.com/keyup/上的详细信息.

这篇关于jQuery更改直到模糊才会触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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