jQuery: Execute after loading of HTML is completed

Other language site
ja ja
Google Translate
  • -

    シェア
  • ---

    LINEで送る
  • -

    はてなブックマーク
    ブックマーク
  • -

    pocket
  • -

    rss
jQuery-Logo

This is a method to execute after loading HTML with jQuery is completed. It's too easy to write and it makes me not understand what you mean.

The method to execute after loading HTML is completed with jQuery is very easy, so let's take a look at the sample suddenly.

(function($) {
    $(function(){
        // Write the process you want to execute after loading HTML here.
    });
})(jQuery);

Just describe $(function () {...});

The loading completion of HTML in jQuery is expressed as $(function () {...}); In JavaScript, it is written as follows.

window.onload = function(){
    ...
}

To be precise, it is when HTML loading is completed and building of DOM is completed.

The DOM (Document Object Model) means to make html tags and attribute information refer to objects (variables).
This is not restricted to html, it is a rule concerning markup language in general such as xml. It is recommended by W3C.

The sample code (function ($) {...}) (jQuery); is to prevent conflict of definition of $, in which $ is recognized as jQuery.
When using $(function () {...});, you'd better decide to write it together.

SNS also distributes articles.
Leave a Reply

*

If you like this article, share it!