-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathindex.html
More file actions
91 lines (81 loc) · 3.33 KB
/
index.html
File metadata and controls
91 lines (81 loc) · 3.33 KB
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
<!DOCTYPE html />
<html>
<head>
<title>Pet Store</title>
<link rel="stylesheet" href="style.css" />
<!-- JS in HTML example
// Simple JS Example
// WINDOW location example
// WINDOW alert example
// WINDOW confirm example
// DOM title example
// Event Handler Examples
-->
<script>
// let dogName = "Stark";
// console.log(dogName);
// console.log(window.location);
// window.alert("OMG! SOMETHING HAPPENED!");
// let response = window.confirm("Click OK if youre having a great time");
// console.log("Are they having a great time? - " + response);
// console.log(document.title);
function changeArnoldTag() {
let arnoldText = document.getElementById("arnold-text");
arnoldText.innerText += " ADOPTED!!";
arnoldText.setAttribute("style", "background-color: red;");
}
function changeLucyTag() {
let lucyText = document.getElementById("lucy-text");
lucyText.innerText += " ADOPTED!!";
lucyText.setAttribute("style", "background-color: red;");
}
function handleOnMouseEnter(elementId) {
let myElement = document.getElementById(elementId);
myElement.setAttribute("style", "background-color: green;");
}
function handleOnMouseLeave(elementId) {
let myElement = document.getElementById(elementId);
myElement.setAttribute("style", "background-color: none;");
}
</script>
<!-- Including JS file in HTML -->
<script src="simple-js.js"></script>
</head>
<body>
<h1>Welcome To Our Pet Store</h1>
<p id="welcome-message">Have a look around!</p>
<section>
<img src="dog.jpeg" style="max-width: 300px;"/>
<p id="arnold-text">Arnold</p>
<script>
// let element = document.getElementById("arnold-text");
// console.log(element);
// element.innerText = "<h1>Arnold!</h1>";
</script>
<button
onmouseover="handleOnMouseEnter('arnold-button')"
onmouseout="handleOnMouseLeave('arnold-button')"
id="arnold-button"
class="pet-adopt-button">Adopt Me!</button>
<script>
let arnoldAdoptBtn = document.querySelector(".pet-adopt-button");
arnoldAdoptBtn.addEventListener('click', changeArnoldTag);
</script>
<!-- Event Listener Example -->
<!-- DOM getElementById example -->
<!-- DOM querySelector example -->
</section>
<br />
<section>
<img src="cat.png" style="max-width: 300px;"/>
<p id="lucy-text">Lucy</p>
<button
onmouseover="handleOnMouseEnter('lucy-button')"
onmouseout="handleOnMouseLeave('lucy-button')"
onclick="changeLucyTag()"
id="lucy-button"
class="pet-adopt-button">Adopt Me!</button>
</section>
<!-- DOM querySelectorAll example -->
</body>
</html>