{"id":177,"date":"2013-11-01T05:24:43","date_gmt":"2013-11-01T05:24:43","guid":{"rendered":"http:\/\/advancedwebhelp.com\/blog\/?p=177"},"modified":"2013-11-02T04:46:46","modified_gmt":"2013-11-02T04:46:46","slug":"jquery-ready-initialization","status":"publish","type":"post","link":"https:\/\/www.advancedwebhelp.com\/blog\/2013\/jquery-ready-initialization","title":{"rendered":"jQuery Ready() Initialization"},"content":{"rendered":"<style type=\"text\/css\"><!--\n<span style=\"overflow:hidden;line-height:0px\" data-mce-style=\"overflow:hidden;line-height:0px\" id=\"mce_0_start\" data-mce-type=\"bookmark\"><\/span><!--\n.sample { float: right ; width: 500px ; height: 150px ; border: 2px solid black ; text-align: left ; padding: 0px !important ; margin-bottom: 20px ; }\n    pre { width: 100% ; height: 100% ; margin: 0px !important ; padding: 0px !important ; }\n--><\/style>\n<h1>Using jQuery initialization<\/h1>\n<p><a href=\"http:\/\/www.advancedwebhelp.com\/blog\/wp-content\/uploads\/2013\/11\/jquery-logo-s.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-329 alignright\" style=\"margin-top: -65px;\" alt=\"jQuery logo\" src=\"http:\/\/www.advancedwebhelp.com\/blog\/wp-content\/uploads\/2013\/11\/jquery-logo-s.jpg\" width=\"208\" height=\"208\" srcset=\"https:\/\/www.advancedwebhelp.com\/blog\/wp-content\/uploads\/2013\/11\/jquery-logo-s.jpg 208w, https:\/\/www.advancedwebhelp.com\/blog\/wp-content\/uploads\/2013\/11\/jquery-logo-s-150x150.jpg 150w, https:\/\/www.advancedwebhelp.com\/blog\/wp-content\/uploads\/2013\/11\/jquery-logo-s-148x148.jpg 148w, https:\/\/www.advancedwebhelp.com\/blog\/wp-content\/uploads\/2013\/11\/jquery-logo-s-31x31.jpg 31w, https:\/\/www.advancedwebhelp.com\/blog\/wp-content\/uploads\/2013\/11\/jquery-logo-s-38x38.jpg 38w\" sizes=\"auto, (max-width: 208px) 100vw, 208px\" \/><\/a>jQuery offers a very convenient method to do JavaScript initialization. Many JavaScript and jQuery statements require existence of site elements and tags, and can not be run until after the elements and tags exist. Some use the onload attribute of the tag. To some, this implies moving the running of the JavaScript or jQuery initialization to the end of the page. However. JavaScript and jQuery offer other methods that solve this problem. They provide methods to run initialization after the DOM hierarchy has been initialized.<\/p>\n<p>jQuery&#8217;s ready() works great to permit the defining of initialization functions and then executing these functions when the DOM is ready.<\/p>\n<p>A reason to use the jQuery ready() initialization rather than javascript.onload() or placing the onload in the body tag &#8230; jQuery allows you to create initialization tasks wherever it is best encapsulated with the code it supports, yet it is gathered together with all other identified initialization activities and executed as a group when the DOM is ready.<\/p>\n<p>To use jQuery ready(), wrap your initialization activities in the ready wrapper as follows:<\/p>\n<aside class=\"sample\">\n<pre><code>\r\n        $(document).ready(function() { \r\n            \/* your initialization to execute *\/ \r\n\r\n        }) ; \r\n        <\/code><\/pre>\n<\/aside>\n<p>&nbsp;<\/p>\n<h1>Shortcut for jQuery Ready() Notation<\/h1>\n<p>Alternately, you may use a shorthand notation to run an initialization by invoking initialization handling as follows:<\/p>\n<aside class=\"sample\">\n<pre><code>\r\n   $(function() {\r\n     \/* Your initialization to be executed *\/\r\n\r\n   }) ;\r\n<\/code><\/pre>\n<\/aside>\n","protected":false},"excerpt":{"rendered":"<p>Using jQuery initialization jQuery offers a very convenient method to do JavaScript initialization. Many JavaScript and jQuery statements require existence of site elements and tags, and can not be run until after the elements and tags exist. Some use the onload attribute of the tag. To some, this implies moving the running of the JavaScript [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-177","post","type-post","status-publish","format-standard","hentry","category-jquery"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/posts\/177","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/comments?post=177"}],"version-history":[{"count":2,"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/posts\/177\/revisions"}],"predecessor-version":[{"id":340,"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/posts\/177\/revisions\/340"}],"wp:attachment":[{"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/media?parent=177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/categories?post=177"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.advancedwebhelp.com\/blog\/wp-json\/wp\/v2\/tags?post=177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}