/
JSHTML02.html
56 lines (35 loc) · 857 Bytes
/
JSHTML02.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
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h2>My First Web Page</h2>
<p>My First Paragraph.</p>
<p id="demo"></p>
// #1 EXAMPLE - Being able to compute with inner html
<script>
document.getElementById("demo").innerHTML = 5 + 6;
</script>
// #1 - you can also write this same thing by shortening that code with a <script> </script>
<script>
document.write5 + 6);
</script>
// #1 - This is a different result
<button onclick="document.write(5 + 6)">Try it</button>
// #1 -And this too
<script>
window.alert(5 + 6);
</script>
<p> #1 - Press F12 for page source, then Select "Console" in the debugger menu. Then click Run again.</p>
<script>
console.log(5 + 6);
</script>
#2 - <script>
var x, y, z;
x = 5;
y = 6;
z = x + y;
document.getElementById("demo").innerHTML = z;
</script>
</body>
</html>