The difference between $ (document). ready (function () {}); and $ (). ready in the script
$ (Document ). the code in ready () is executed only after the page content is loaded. If you directly write the code to the script tag, after the script tag is loaded on the page, the code in it will be executed. If the code executed in your tag calls the code or dom that has not been loaded yet, an error will be reported, of course, if you put the script tag at the end of the page, there will be no problem. This is the same as ready.
$ (Document). ready (function () {}) can be abbreviated to $ (function (){});
After clicking a paragraph, this paragraph is hidden:
If you remove $ (document). ready (function () {});, the Section cannot be hidden:
However, if you put the script at the end of the page, the hiding effect can be restored:
$ (Document) ready (function () {}); what is the difference between writing and not writing?
$ (Document ). the code in ready is executed only after the page content is loaded. You can directly write it to the script tag. After the script tag is loaded on the page, the code in the script will be executed, if the code executed in your tag calls the code or dom that has not been loaded yet, an error will be reported,
Of course, if you set the script tag to the end of the page, there will be no problem with ready.
In jquery, what is the difference between $ (document) ready (function () {}); and $ () ready (function?
Shorthand
$ (Document). ready (function (){});
$ (). Ready (function (){});
Yes
$ (Function () {}) is the shortest ~~