Skip to content

Commit e6a318e

Browse files
committed
.
1 parent 52beff7 commit e6a318e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Global Variables in HTML1.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<body>
5+
6+
<h2>JavaScript Global Variables</h2>
7+
8+
<p>In HTML, global variables defined with <b>var</b>, will become window variables.</p>
9+
10+
<p id="demo"></p>
11+
12+
<script>
13+
var carName = "Volvo";
14+
15+
// code here can use window.carName
16+
document.getElementById("demo").innerHTML = "I can display " + window.carName;
17+
</script>
18+
</body>
19+
20+
</html>

0 commit comments

Comments
 (0)