jQuery Form Events With Examples
.blur() method
When there is loss of focus on an element, the blur event occurs.
Example of jQuery blur method
$("input,select,textarea").
blur(function () {
//do something
});
.change() method
When the value of a checkbox, radio button, or textbox is changed, the jQuery change event is triggered.
Example of jQuery change method
$("input,select,textarea").
change(function () {
//do something
});
.focus() method
The focus()
method triggers the focus event, or attaches a function to run when a focus event occurs.
The focus method in jQuery is used for triggering a focus event. In simple words, this method makes the functions to run during the occurrence of a focus event.
Example of jQuery focus method
$("input,select,textarea").
focus(function () {
//do something
});
.select() method
It only triggers when the text inside the element is highlighted, and it's confined to textboxes and textareas.
Example of jQuery select method
$("input,textarea").
focus(function () {
//do something
});
.submit() method
When attempting to submit a form, this event is triggered, and it is bound to the form element only.
Example of jQuery submit method
$("form").
focus(function () {
//do something
});