开发者

jquery: getting any change event on any form

开发者 https://www.devze.com 2023-03-25 03:11 出处:网络
I know I can get any change event on one form by using this code: $(\"开发者_运维百科#testForm :input\").change(function() {

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'));      
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号