Skip to content

Commit a027005

Browse files
yesthatguyAurelioDeRosa
authored andcommitted
Replace $(window).load with $(window).on( "load" )
Closes jquerygh-736
1 parent 3ed1f8e commit a027005

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

page/using-jquery-core/document-ready.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"level": "beginner"
44
}</script>
55

6-
A page can't be manipulated safely until the document is "ready." jQuery detects this state of readiness for you. Code included inside `$( document ).ready()` will only run once the page Document Object Model (DOM) is ready for JavaScript code to execute. Code included inside `$( window ).load(function() { ... })` will run once the entire page (images or iframes), not just the DOM, is ready.
6+
A page can't be manipulated safely until the document is "ready." jQuery detects this state of readiness for you. Code included inside `$( document ).ready()` will only run once the page Document Object Model (DOM) is ready for JavaScript code to execute. Code included inside `$( window ).on( "load", function() { ... })` will run once the entire page (images or iframes), not just the DOM, is ready.
77

88
```
99
// A $( document ).ready() block.
@@ -32,10 +32,10 @@ function readyFn( jQuery ) {
3232
3333
$( document ).ready( readyFn );
3434
// or:
35-
$( window ).load( readyFn );
35+
$( window ).on( "load", readyFn );
3636
```
3737

38-
The example below shows `$( document ).ready()` and `$( window ).load()` in action. The code tries to load a website URL in an `<iframe>` and checks for both events:
38+
The example below shows `$( document ).ready()` and `$( window ).on( "load" )` in action. The code tries to load a website URL in an `<iframe>` and checks for both events:
3939

4040
```
4141
<html>
@@ -46,7 +46,7 @@ The example below shows `$( document ).ready()` and `$( window ).load()` in acti
4646
console.log( "document loaded" );
4747
});
4848
49-
$( window ).load(function() {
49+
$( window ).on( "load", function() {
5050
console.log( "window loaded" );
5151
});
5252
</script>

0 commit comments

Comments
 (0)