forked from valfragier16/JavaScript-DOM
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathjs-dom.html
More file actions
43 lines (32 loc) · 1003 Bytes
/
js-dom.html
File metadata and controls
43 lines (32 loc) · 1003 Bytes
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
<!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>
<p id="Coders" style="color:blue; font-size: 40px;">Developers for life!</p>
<p id="Developers" style="color: red">We are coders!</p>
<img id="myImg" src="https://www.new-startups.com/wp-content/uploads/unsplash-images-free.jpg" alt="The Pulpit Rock" width="304" height="228">
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myImg").src;
document.getElementById("demo").innerHTML = x;
}
</script>
<button onclick="myFunction()">Click Me!</button>
<div id="myImg"></div>
<script>
function myFunction() {
var x = document.getElementById("myImg");
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}
</script>
</body>
</html>