12JQuery notes----------------------events in jquery

Source: Internet
Author: User

11, (*) Event Binding in jquery:2$ ("#btn"). Bind ("click",function() {}), which is so cumbersome to call every time,3So jquery can be used for $ ("#btn"). Click (function() {}) for simplification. Unbind4     5     62, MouseOver, mouseenter the difference: div in a set of Div. See Remarks. is related to event bubbling. 7 8 93, (*Synthetic event Hover,hover (ENTERFN,LEAVEFN), called ENTERFN when the mouse is placed on the elementTen Call the Leavefn method when the mouse leaves the element.  One      A      -4, event bubbling: jquery, like JavaScript, is event bubbling. -The way to block events from bubbling is:return false; the If you want to get event-related information, just add a parameter to the anonymous function of the response: E,e is the event object. Invokes the Stoppropagation () method of the event object to terminate the bubbling. E.stoppropagation (); -$ ("tr"). Click (function(e) {alert ("tr is clicked"); E.stoppropagation ();});//Note that the arguments to the function are e to block the default behavior: Some elements have default behavior, such as hyperlinks to new links when clicked, the Submit button submits the form by default, if you want to block the default behavior as long as the Preventdefault () of the event object is called Method is the same as the Window.event.returnvalue=false effect in the DOM. $ ("a"). Click (function (e) {alert ("All hyperlinks are temporarily forbidden to click"); - E.preventdefault ();}); -      +5, Toggle (function() {}) method, which is executed automatically when the page is imported. When registering multiple events, you will - execute in turn.  +      A6, properties: PageX, Pagey, Target gets the element that triggered the event (the start of the bubble, and this is not the same), which if the mouse event gets the keys (1 left, 2 middle, 3 right). Altkey, Shiftkey, Ctrlkey get ALT, SHIFT, CTRL is pressed, is bool value. KeyCode, CharCode property occurs when the event is KeyCode (keyboard code, keypad 1 and the main keyboard keycode not the same), CharCode (ASC code).  at  -  -7. Remove event Bindings: The Bind () method removes all bound events on the element, and if unbind ("click") removes only the bindings for the Click event. bind:+=;unbind:-=One -time event: If the bound event only wants to execute once and then immediately unbind can use the one () method for event binding. -  -  -8. $ (' #btn '). Click ({"Name": "Pony"},function(EEE) { in alert (eee.data.name); -             }); to When you create a method, you can pass in a parameter.  +9, 1, (*) Event Binding in jquery: -$ ("#btn"). Bind ("click",function() {}), which is so cumbersome to call every time, theSo jquery can be used for $ ("#btn"). Click (function() {}) for simplification. Unbind *      $     Panax Notoginseng2, MouseOver, mouseenter the difference: div in a set of Div. See Remarks. is related to event bubbling.  -  the  +3, (*Synthetic event Hover,hover (ENTERFN,LEAVEFN), called ENTERFN when the mouse is placed on the element A Call the Leavefn method when the mouse leaves the element.  the      +      -4. Event bubbling: Like JavaScript in jquery, event bubbling prevents events from bubbling by:return false; $ If you want to get event-related information, just add a parameter to the anonymous function of the response: E,e is the event object.  $ invokes the Stoppropagation () method of the event object to terminate the bubbling. E.stoppropagation (); -$ ("tr"). Click (function(e) {alert ("tr is clicked")); E.stoppropagation (); }); -     //Note that the parameter of the function is e to block the default behavior: the Some elements have default behavior, such as hyperlinks to the new link after the click, the Submit button will submit the form by default, -If you want to block the default behavior, just call the event object's Preventdefault () method and the Window.event.returnvalue=false effect in the DOM. $ ("a"). Click (function(e) {alert ("All hyperlinks are temporarily forbidden to click");Wuyi E.preventdefault ();}); the      -5, Toggle (function() {}) method, which is executed automatically when the page is imported.        When multiple events are registered, they are executed sequentially.  Wu      -6, properties: PageX, Pagey, Target get the element that triggered the event (the start of the bubble, and this is not the same), About which if the mouse event is obtained press (1 left, 2 middle, 3 right).  $ Altkey, Shiftkey, Ctrlkey get ALT, SHIFT, CTRL is pressed, - is a bool value. KeyCode, CharCode property occurs when an event is KeyCode - keyboard code, the keypad 1 and the main keyboard keycode different), CharCode (ASC code).  -  A  +7, remove event bindings: The Bind () method removes all bound events on the element, theIf the unbind ("click") removes only the bindings for the Click event.  -bind:+=;unbind:-=One -time event: If the bound event only wants to execute once and then immediately unbind can use the one () method for event binding: $  the  the8. $ (' #btn '). Click ({"Name": "Pony"},function(EEE) { the alert (eee.data.name); the             }); - When you create a method, you can pass in a parameter.  in  the  the9to get the position of the mouse when an event occurs About$ (document). MouseMove (function(e) {document.title = E.pagex + "," + E.pagey;}); If you specify a parameter E in an anonymous response function for an event such as MouseMove, click, you can read some information from E, such as mouse events such as MouseMove, to read E.pagex, E.pagey to get the coordinates of the mouse in the page when the event occurs.

12JQuery notes----------------------events in jquery

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.