27. Jquery Events

Source: Internet
Author: User

Jquery Events

In JavaScript, events are invoked in the same way as OnClick, onmouseover, and so on, using events in jquery without writing the previous on

Bind () method

Binding an event to an element

$ ("#id"). Bind ("click",function() {    //// for ID binding Click event    alert ("OK"

Events that are bound using the bind () method are multicast event delegates, that is, events that are defined again do not overwrite the previous event

// you can execute two events $ ("#id") sequentially. Bind ("click",function() {alert ("1");}); $ ("#id"). Bind ("click",function() {alert ("2")});

One () method

Binding One-time events

// A single-click operation will no longer execute $ ("#id") the next time. One ("click",function() {    alert ("a");     return false ;});

Unbind () method

Delete event, unbind

// Delete all events of ID // Delete all click events for ID

Quick Events

JavaScript events are removed on basic support

Click () method

Click events

// If the function body is not written, the event is immediately triggered by $ ("#id"). Click (function() {    // This is a click event });

Dbclick () method

Double-click event

// Trigger Event $ ("#id"). Dbclick (function() {    // double-click to execute });

Focus () method

Get focus

// Trigger $ ("#id"). Focus (function() {    // get focus after execution });

Blur () method

Lose focus

// triggers the loss of focus event $ ("#id"). blur (function(    ) {// lose focus after execution });

Change () method

When changing

// triggers the Change event $ ("#id"). Changes (function()    {// change after execution });

MouseOver () method

Mouse Move in

$ ("#id"). MouseOver (); $ ("#id"). MouseOver (function() {});

Mouseout () method

Mouse move out

$ ("#id"). Mouseout (); $ ("#id"). Mouseout (function() {});

Submit () method

Submit Form

$ ("#id"). Submit (); $ ("#id"). Submit (function() {});

Hover () method

Used to solve the problems of mouseover and mouseout

// two function corresponding to move in and move out $ ("div"). Hover (function() {    $ ("div"). HTML ("Ah ah ah ah ah oh, run, he's coming."  );},function() {    $ ("div"). html ("cried, scared to the end, finally gone!") ")});

Toggle () method

Execute each function sequentially, if execution is done repeatedly

$ ("#div"). Toggle (    function() {        $ ("#div"). CSS ({"width": "100px" })    ,     function () {        $ ("#div"). CSS ({"width": "200px" });    },    function() {        $ ("#div"). CSS ({"width": "300px" });    

Jquery Event Object

The Jquery event merges different browser differences, such as event.target can be used in all browsers to get the trigger without judging the browser's use of srcelement.

$ ("#div"). Click (function(e) {    // return event name click    // return event source who triggered the     //    alert (e.screenx);  //... Wait for the event in JS });

27. Jquery Events

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.