JQuery event bind () method

Source: Internet
Author: User

The bind () method adds one or more event handlers to the selected element, and specifies the function to run when the event occurs.

$ (selector). bind (Event,data,function)//syntax

Event required. Specifies one or more events that are added to an element, separated by a space from multiple events. Must be a valid event:

data: Optional. Specifies additional data that is passed to the function.

function: required. Specifies the function to run when an event occurs.

$ ("button"). Bind ("click", Function () {  $ ("P"). Slidetoggle ();});

The previous example hides or displays the P element when you click the mouse

2 syntax

$ (selector). Bind ({event:function, event:function, ...})

Event:function, Event:function,: Required. Specifies the event map, which contains one or more events added to the element, and functions that run when the event occurs.

$ (document). Ready (function () {  $ ("button"). Bind ({    click:function () {$ ("P"). Slidetoggle ();},    Mouseover:function () {$ ("body"). CSS ("Background-color", "Red");},      Mouseout:function () {$ ("body"). CSS (" Background-color "," #FFFFFF ");}    );});

The previous example hides or displays the P element when the mouse is clicked,

Obody background color turns red when mouse moves to button

Obody background color turns white when mouse button is removed

JQuery event bind () method

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.