jQuery检测对字段的程序化更改 [英] jQuery detect programatic change to field

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

问题描述

我有一个名为#myHiddenField的隐藏字段.

I have a hidden field called #myHiddenField say.

该字段的内容在各个地方都以编程方式进行了更改.

The content of this field is programatically changed at various places.

我想要一种检测该变化的方法.除非我输入字段,否则更改事件不会触发,但这是不可能的.

I'd like a method that detects that change. The change event won't fire unless I type into the field but this is impossible.

是否存在一种jQuery方法来检测字段中的程序化内容更改?

Is there a jQuery way to detect programatic content change in a field?

推荐答案

您应该能够通过以下方式触发更改事件:

You should be able to trigger the change event with:

$('#myHiddenField').change();

OR

$('#myHiddenField').trigger('change');

当然,这需要代码块来负责更新文件,以便在文件完成工作后进行其中之一的调用.

Of course this will require the block of code responsible for updating the filed to make one of those calls after it has done its work.

这篇关于jQuery检测对字段的程序化更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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