forked from ArchanaAvv/June2015
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocReady.html
59 lines (42 loc) · 1.36 KB
/
docReady.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="jquery-1.11.3.js"></script>
<script type="text/javascript">
// console.log($('#headingTitle').length);// 0
function onDocumentReadyHandler(){
console.log($('#headingTitle').length);// 1
} // function declaration
$('document').ready(onDocumentReadyHandler); //event registration
$('document').ready(function(){
console.log($('#headingTitle').length);// 1
});//anonymys function
$(function(){
console.log($('#headingTitle').length);
}); //third way of writing document. ready
// onDocumentReadyHandler();
// sum(10,function(){
// return 20;
// })
//
// function sum(a,b){
// //b
// return a + b();
// }
</script>
</head>
<body>
<!-- document.ready makes sure that your jquery code is executed
after all the dom elements are loaded -->
<h1 id="headingTitle" >Welcome Javascript Developers.</h1>
<script type="text/javascript">
//console.log($('#headingTitle').length); //1
function onDocumentReadyHandler(){
console.log($('#headingTitle').length);// 1
}
$('document').ready(onDocumentReadyHandler); //event registration
</script>
</body>
</html>