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