html隐藏字段的更改事件 [英] change event of html hidden field

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

问题描述

我想使用jquery检查html隐藏字段的更改,我尝试这样做,但是change事件没有起作用.

I want to check the change of html hidden field using jquery and i tried for this but the change event did not worked.

有人知道如何处理吗?

Somebody has and idea how to handle this?

推荐答案

通过以编程方式更改的值时,不会触发change事件,如果这样做会在许多情况下导致无限循环情况.

The change event doesn't fire when the value is programmatically changed, if it did it would cause infinite loops in many situations.

如果您需要触发该事件,请在使用 .change() ,像这样:

If you need the event to fire, then trigger it when changing the value yourself using .change(), like this:

$("#hiddenId").val("new value").change();

.change() ,或者,如果您由于某种原因希望该change事件冒泡,请使用 .triggerHandler("change") .

.change() is a shortcut for .trigger("change") or, if you don't want that change event to bubble for some reason, then use .triggerHandler("change").

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

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