JQuery - function call at any time when the user changes input of any form?

I have a page with several forms. At any time, when the user clicks on the input or changes the text in the input line, I need a function that you call. Any ideas on how to do this efficiently and in what form, where does it not require form identifiers?

+3
source share
2 answers

JavaScript events pop up. So what about:

$('form').change(function() {
    // do something
}).click(function() {
    // do something
});

In each case, you can request the element that triggered the event and do what you like.

+10
source
$('form input').each(function() {
     var val = this.value;
     $(this).click(function() { }
     $(this).blur(function() {
     }

});

. .

+2

Source: https://habr.com/ru/post/1754047/


All Articles