如何检查模糊事件是否更改了值? [英] How can I check if a value is changed on blur event?

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

问题描述

基本上,我需要检查'blur'事件中文本框中的值是否已更改,以便如果未更改该值,则要取消blur事件。

Basically I need to check if the value is changed in a textbox on the 'blur' event so that if the value is not changed, I want to cancel the blur event.

如果可以检查它的值是由用户在输入HTML元素的模糊事件上更改的?

If it possible to check it the value is changed by user on the blur event of an input HTML element?

推荐答案

我认为没有本地方法可以做到这一点。我要做的是,向 focus 事件添加一个函数,该函数将当前值保存到附加到元素的变量中( element.oldValue = element .value )。您可以在BLur上检查该值。

I don't think there is a native way to do this. What I would do is, add a function to the focus event that saves the current value into a variable attached to the element (element.oldValue = element.value). You could check against that value onBLur.

这篇关于如何检查模糊事件是否更改了值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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