admin管理员组文章数量:1222503
I have a form with multiple input checkbox fields. I want to trigger form submit on change in any of the checkbox without submit button.
<form action="" method="get">
<input type="checkbox" name="p[]" value="1">
<input type="checkbox" name="p[]" value="2">
<input type="checkbox" name="p[]" value="3">
</form>
How it can be done with jQuery?
I have a form with multiple input checkbox fields. I want to trigger form submit on change in any of the checkbox without submit button.
<form action="" method="get">
<input type="checkbox" name="p[]" value="1">
<input type="checkbox" name="p[]" value="2">
<input type="checkbox" name="p[]" value="3">
</form>
How it can be done with jQuery?
Share Improve this question edited Aug 3, 2016 at 8:15 Rory McCrossan 338k41 gold badges320 silver badges351 bronze badges asked Aug 3, 2016 at 8:13 Anuj TBEAnuj TBE 9,79034 gold badges146 silver badges304 bronze badges1 Answer
Reset to default 16You could hook to the change()
event of the checkboxes, then fire a submit()
on the parent form
, like this:
$('form input').on('change', function() {
$(this).closest('form').submit();
});
本文标签: javascriptSubmit form on change of input fieldStack Overflow
版权声明:本文标题:javascript - Submit form on change of input field - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1739283627a2156358.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论