-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirst.html
95 lines (73 loc) · 2.14 KB
/
first.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!-- Javascript Tutorial. My first javascript.W3schools practice
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h2>My first javascript</h2>
<button type="button"
onclick="document.getElementById('demo').innerHTML=Date()"> Click me to
display date and time
</button>
<p id="demo"></p>
</body>
</html>
***some examples of what javascript can do**** 1.javascript can change HTML content
getElmentById is one of the javascript element which can change the element content. To do this
it finds an HTML element by its id and changes its innerHTML or element content
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h2>What javascript can do?</h2>
<p id="demo" >Javascript can change the HTML content</p>
<script>
document.getElementById("demo").innerHTML = "My first Javascript ";
</script>
</body>
</html>
JavaScript in <head> or <body> Javascript can be placed in the head or body tag section
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
function myFunction(){
document.getElementById("demo").innerHTML="Paragraph changed";
}
</script>
</head>
<body>
<h1>Javascript in Head tag</h1>
<p id="demo">
A paragrapg
</p>
<button type="button" onclick="myFunction()">
Try it
</button>
</body>
</html> -->
<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "Paragraph changed.";
}
</script>
</head>
<body>
<h2>JavaScript in Head</h2>
<p id="demo">A Paragraph.</p>
<button type="button" onclick="myFunction()">Try it</button>
</body>
</html>