如何触发隐藏字段的onChange事件? [英] How do I trigger an onChange event for a hidden field?

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

问题描述

我想为隐藏字段
发起一个onChange事件大多数我读过的论坛表明,onChange不适用于隐藏字段
所以有没有办法解决这个问题,类似于Plan-B?

解决方案

在jQuery中,您可以触发自定义事件:

  $(#hidden_​​input_id)。trigger(special-change); 

你可以听:

<$ p (special-change,function(){

}); $ p> $(#hidden_​​input_id)。

DEMO: http://jsfiddle.net/byKak/

参考:


I want to fire an onChange event for hidden field, Most of the forums I've read suggests that onChange doesn't work for hidden fields, So is there a way around for that, something like Plan-B?

解决方案

In jQuery, you could trigger a custom event:

$("#hidden_input_id").trigger("special-change");

And you can listen with:

$("#hidden_input_id").on("special-change", function () {

});

DEMO: http://jsfiddle.net/byKak/

Reference:

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

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