Sharp Jquery--jquery event, animation (reading Note II)

Source: Internet
Author: User

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)

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.