"Sharp jquery" events in jquery

Source: Internet
Author: User

1, $ (document). The difference between the ready () method and the Window.onload method

$ (document). Ready (function(){        //Code    })//Shorthand//$ (function () {////Code//    });window.onload=function(){        //Code    }//equivalent to//$ (window). Load (function () {////Code//    })

① execution Time: The former can be called when the DOM is fully ready, which is executed when all the elements in the Web page (including all associated files of the element) are fully loaded into the browser, that is, JavaScript can now access any element in the page. (Note: The former when the HTML related to the picture has been parsed into a DOM tree, but it is possible that the picture is not loaded, the height and width of the picture is not necessarily valid at this time, using the load () method, the equivalent of JS's onload ())

② multiple use: The latter JavaScript onload event can only hold a reference to a function at a time. The former can be executed sequentially.

2. Event Binding

    $ (function  () {        $ (function  () {            var $content = $ ( This ). Next ();             if ($content. Is (": Visible")) {                $content. Hide ();             Else {                $content. Show ();            }        );    });

3. Change the Binding event type

"Sharp jquery" 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.