1. Note The fine difference between the ready () method and the Window.onload method$ (document). Ready () is executed when the DOM tree is built, and window.onload is done after the DOM tree is built andThe relevant files will not be executed until they have been downloaded.Example: A gallery page that binds an event to a page slice$ (document). Ready () will be executed on the DOM structure of the Gallery page, but this time the picture on the page has not been downloaded, the image is bound to theEvents will not work. At this point, if you want to get the width of the picture will fail. to solve this problem: You can use the following in jquery:$ (window). Load (function () {}) This function is similar to the one in javascript:window.onload=function () {} The window.onload is not executed until all pictures have been downloaded and the event is bound. The disadvantage is that the page loading speed is affected.
2.jQuery is () and next ()
3. Event bubbling The click of the span bubbles to the Click,div click of the div to bubble to the body's click. Sometimes this bubble is worse if it's not what you want it to be. because you trigger a span Click event will also trigger the DIV, triggering the body.
ways to block bubbling in jquery:even.stoppropagation ();
blocking the default behavior in jquery:Even.preventdefault ();
also block bubbling with the default behavior:return false; is a shorthand.
3. Properties of the event objectEvent.type ()event.stoppropagation ()Even.preventdefault ();event.target ();event.relatedtarget ();Event.pagex ()/event.pagey ( )Event.which ();Event.metakey ();event.originalevent ();
4. Simulate event actions
<1>$ ("#but"). Trigger ("click");$ ("#but"). Click ();simulates the click behavior.
<2>trigger can trigger not only the browser-supported events , but also the custom events . $ ("#but"). Bind ("Zqzclick", function () {alert ("This is Zqz's custom event");});$ ("#but"). Trigger ("Zqzclick");$ ("#but"). Zqzclick ();---------don't know how to write this, okay?
<3>Trigger binding Data
<4>triggerhandler ()
<5>bind () can bind multiple events
<6> Add event namespaces for easy AdministrationDelete will only delete under the namespace.
<7> Stop Animation$ (this). Stop (true)
// determines whether an element is in an animated state. If(!$ (Element). Is (": Animated")) { }
Sharp Jquery--jquery event, animation (reading Note II)