Cach 1:
// A $( document ).ready() block.
$( document ).ready(function() {
console.log( "ready!" );
});
Cach 2:
// Shorthand for $( document ).ready()
$(function() {
console.log( "ready!" );
});
Cach 3:
// Passing a named function instead of an anonymous function.
function readyFn( jQuery ) {
// Code to run when the document is ready.
}
$( document ).ready( readyFn );
// or:
$( window ).load( readyFn );
VD:
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$( document ).ready(function() {
console.log( "document loaded" );
});
$( window ).load(function() {
console.log( "window loaded" );
});
</script>
</head>
<body>
<iframe src="http://techcrunch.com"></iframe>
</body>
</html>
No comments:
Post a Comment