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?
Asked
Active
Viewed 1.1k times
5
-
Can you give us your scenario? – Austin Brunkhorst May 17 '13 at 04:46
-
For the hidden field how can you add onChange event..??for that also you need to depend on one of visible field right..?? – GautamD31 May 17 '13 at 04:50
1 Answers
10
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/

Ian
- 50,146
- 13
- 101
- 111
-
1You can also trigger regular change event this way `$("#hidden_input_id").trigger("change");` and then regular `onChange` will trigger. Or using plain JS http://stackoverflow.com/a/1003155/758991 – Ruslan Stelmachenko May 05 '16 at 13:06