1. Basic syntax for jquery functions:
$ (document). Ready (function () {
code block;
})
2.window.onload () and $ (document) the distinction between ready ():
1) window.onload () It is time to wait for all content in the Web page to be loaded (including pictures) to execute, $ (document). Ready () executes after all DOM structures are drawn in the Web page
2) Number of writes:
Window.onload () cannot execute multiple simultaneously: for example
Window.onload () =function () {
Alert ("First");
}
Window.onload () =function () {
Alert ("Second");
}
The results only output "Second".
$ (document). Ready () can write multiple executions: for example
$ (document). Ready (function ()
{
Alert ("Hello first!");
});
$ (document). Ready (function ()
{
Alert ("Hello second!");
});
Two will output, and sequentially output;
3) Simplified notation:
$ (document). Ready (function ()
{
code block;
});
Simplified:
$ (function () {
code block;
});
Simple functions of jquery