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

我想使用jquery检查html隐藏字段的更改,我试过这个但是更改事件没有用。

Somebody has and idea how to handle this?

有人有和想法如何处理这个?

2 个解决方案

#1


78

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

当以编程方式更改值时,更改事件不会触发,如果它确实在许多情况下会导致无限循环。

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

如果您需要触发事件,则在使用.change()更改值时触发它,如下所示:

$("#hiddenId").val("new value").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").

.change()是.trigger(“更改”)的快捷方式,或者,如果由于某种原因不希望该更改事件冒泡,则使用.triggerHandler(“更改”)。

更多相关文章

  1. JQuery 总结(3) jQuery 各种事件
  2. jQuery 选择器 与 事件
  3. jquery不会对select/选项更改事件作出反应。
  4. 使用HTML5验证时如何绑定到提交事件?
  5. jquery自定义事件
  6. Symfony 2在用户站点上动态添加字段以形成
  7. jQuery学习笔记- focus和blur事件妙用
  8. 具有嵌套元素的jQuery悬停事件
  9. 用jquery 绑定一个按钮click事件后,第一次点击后,一切正常,第二次点

随机推荐

  1. Byte Buddy - java.lang.NoSuchMethodE
  2. Eclipse打开出错:Java wa started but ret
  3. Java String类具体解释
  4. javascript获得客户端IP的又一方法
  5. 根据用户的动态字段对链接列表进行排序
  6. (翻译)Java使用POI中的SXSSF处理大数据量
  7. 爬虫6:多页面增量Java爬虫
  8. JAVA-简单Swing图形化界面
  9. java 正则表达式查找某段字符串中所有小
  10. 黑马程序员——Java学习笔记 String类和