每次特定表单输入字段更改时,我都会使用以下代码段进行检测。
$( '#textbox' ).on( 'input', function() {
// Do something here
});
此特定输入字段属于具有复选框,单选按钮和更多文本输入字段的表单。有没有办法检测何时对表单的任何字段进行更改?
答案 0 :(得分:9)
尝试,
$('#Form input').on( 'input', function() {
//This would be called if any of the input element has got a change inside the form
});
答案 1 :(得分:6)
试试这个:
<强> HTML:强>
<form>
<p><input type='text' /></p>
<p><input type='text' /></p>
<p><input type='checkbox' /></p>
</form>
<强> JQuery的:强>
$('form :input').change(function(){
alert("Form changed");
});
<强> JSFiddle Demo 强>
答案 2 :(得分:3)
$("form :input").change(function() {
});