Or, asked another way, do hidden form elements (<input type="hidden"... />
) support jQuery's click()
method?
Asked
Active
Viewed 8,920 times
8

Jeromy French
- 11,812
- 19
- 76
- 129
1 Answers
10
Yes, hidden inputs work with the click()
method. You can't click on a hidden input element with your mouse, but you can execute the click event using the click method.
So, given this HTML:
<form>
<input type="hidden" name="input1" id="input1" value="Yes">
</form>
You can assign a click handler:
$('#input1').click(function () {
//do something
});
and invoke the click event:
$('#input1').click();
See http://jsfiddle.net/jhfrench/v6LUd/ for a working example.

Jeromy French
- 11,812
- 19
- 76
- 129