开发者

jquery: getting any change event on any form

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜