How do I trigger an onChange event for a hidden field?

拜拜、爱过 提交于 2019-12-01 03:57:11

问题


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?


回答1:


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:

  • .trigger(): http://api.jquery.com/trigger/


来源:https://stackoverflow.com/questions/16601556/how-do-i-trigger-an-onchange-event-for-a-hidden-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!