Jquery change and bind event code:
First, the jquery Event change () method
The Change event occurs when the value of the element changes. This event applies only to the Text field and the SELECT element.
Note: When used with a SELECT element, the Change event occurs when an option is selected. When used with the text field or text area, the event occurs when the element loses focus.
= = "Basic syntax:
$ (selector). Change ()//Trigger Change event for selected element
To bind a function to a change event:
$ (' input[type= ' text "] '). Change (function () {...}); A function that specifies that the change event of the selected element should be run when
When you bind a text box:
$ (function () {
$ (' #myText '). Change (function () {...});
});
Ii. jquery Event bind () method
The bind () method adds one or more event handlers to the selected element and specifies the function to run when the event occurs
= = "Basic syntax:
$ (selector). bind (Event,data,function)
where event (required) specifies one or more events to be added to the element, with spaces separating multiple events (must be valid events). Data (optional) specifies additional data to be passed to the function. function (required) specifies the functions that run when an event occurs.
Example: $ (' #myText '). Bind (' click ', function () {
Alert ($ (' #myText '). Val ());
});
$ (' #myText '). Bind (' MouseEnter mouseleave ', function () {...});
Alternative syntax:
$ (selector). Bind ({event:function, event:function,...})
9.17Jquery Change and bind