I know I can get any change event on one form by using this code:
$("开发者_运维百科#testForm :input").change(function() {
console.log($(this).attr('name'));
});
How would I get it if I have multiple forms?
Either do something like that which will get all changes to all form inputs, or give each separate form an ID.
$("form :input").change(function() {
console.log($(this).attr('name'));
});
$("form :input").change(function() {
console.log($(this).attr('name'));
});
for all forms, but if you still want only that one form
$("#testForm :input").change(function() {
console.log($(this).attr('name'));
});
Try with tag selector
$("form :input").change(function() {
console.log($(this).attr('name'));
});
精彩评论