9.17Jquery Change and bind

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.