Reputation: 6384
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?
Upvotes: 2
Views: 12721
Reputation: 6608
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'));
});
Upvotes: 4
Reputation: 69915
Try with tag selector
$("form :input").change(function() {
console.log($(this).attr('name'));
});
Upvotes: 2
Reputation: 78550
$("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'));
});
Upvotes: 3