You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You cannot safely manipulate a page until the document is “ready.” jQuery detects this state of readiness for you; code included inside `$(document).ready()` will only run once the page is ready for JavaScript code to execute.
9
+
10
+
<divclass="example"markdown="1">
11
+
A $(document).ready() block
12
+
13
+
$(document).ready(function() {
14
+
console.log('ready!');
15
+
});
16
+
</div>
17
+
18
+
There is a shorthand for `$(document).ready()` that you will sometimes see; however, I recommend against using it if you are writing code that people who aren't experienced with jQuery may see.
19
+
20
+
<divclass="example"markdown="1">
21
+
Shorthand for $(document).ready()
22
+
23
+
$(function() {
24
+
console.log('ready!');
25
+
});
26
+
</div>
27
+
28
+
You can also pass a named function to `$(document).ready()` instead of passing an anonymous function.
29
+
30
+
<divclass="example"markdown="1">
31
+
Passing a named function instead of an anonymous function
0 commit comments