jQuery文本框更改事件 [英] jQuery textbox change event

查看:64
本文介绍了jQuery文本框更改事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

文本输入元素没有更改事件吗?当我将更改事件处理程序附加到文本输入时,不会触发它.触发了Keyup,但是keyup不足以检测更改,因为显然还有其他将文本输入到输入中的方法.

Does text input element not have a change event? When I attach a change event handler to a text input it is not being fired. Keyup is fired, but keyup is not sufficient for detecting a change as there are obviously other ways of entering text into an input.

推荐答案

对此没有真正的解决方案-即使在上述其他问题的链接中也是如此.最后,我决定使用setTimeout并调用一个每秒检查一次的方法!这不是一个理想的解决方案,但是一个可以正常工作且我正在调用的代码的解决方案非常简单,不会一直被调用而影响性能.

There is no real solution to this - even in the links to other questions given above. In the end I have decided to use setTimeout and call a method that checks every second! Not an ideal solution, but a solution that works and code I am calling is simple enough to not have an effect on performance by being called all the time.

function InitPageControls() {
        CheckIfChanged();
    }

    function CheckIfChanged() {
        // do logic

        setTimeout(function () {
            CheckIfChanged();
        }, 1000);
    }

希望这对以后的人有所帮助,因为似乎没有确定的方法可以使用事件处理程序来实现这一目标...

Hope this helps someone in the future as it seems there is no surefire way of acheiving this using event handlers...

这篇关于jQuery文本框更改事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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