-
Notifications
You must be signed in to change notification settings - Fork 0
/
index3.html
88 lines (70 loc) · 2.29 KB
/
index3.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
<!DOCTYPE html>
<html>
<head>
<style>
* {
border-style: solid;
border-color: red;
}
</style>
</head>
<body>
<h1>JavaScript Strings</h1>
<p>Property acces on strings are read only:</p>
<p id="demo1">old text 1</p>
<p id="resultHere">old text 2</p>
<p id="demo1">old text 3</p>
<label for="weather">Select the weather type today: </label>
<select id="weather">
<option value="">--Make a choice--</option>
<option value="sunny">Sunny</option>
<option value="rainy">Rainy</option>
<option value="snowing">Snowing</option>
<option value="overcast">Overcast</option>
</select>
<p>Replace "Microsoft" with "W3Schools" in the paragraph below:</p>
<button onclick="myFunction()">Try it</button>
<p id="demo2">Please visit Microsoft!</p>
<button onclick="troubleshooting()">Troubleshooting</button>
<p id="demo3">troubleshooting demo3 here</p>
<script>
let text = "HELLO WORLD";
document.getElementById("demo1").innerHTML = text;
const selection = document.querySelector("#weather");
const reply = document.querySelector("p#resultHere");
selection.addEventListener("change", setWeather);
function setWeather() {
const choice = selection.value;
if (choice === "sunny") {
reply.textContent =
"It is nice and sunny outside today. Wear shorts! Go to the beach, or the park, and get an ice cream.";
} else if (choice === "rainy") {
reply.textContent =
"Rain is falling outside; take a rain coat and an umbrella, and don't stay out for too long.";
} else if (choice === "snowing") {
reply.textContent =
"The snow is coming down — it is freezing! Best to stay in with a cup of hot chocolate, or go build a snowman.";
} else if (choice === "overcast") {
reply.textContent =
"It isn't raining, but the sky is grey and gloomy; it could turn any minute, so take a rain coat just in case.";
} else {
reply.textContent = "";
}
}
function myFunction() {
document.getElementById("demo2").innerHTML = document.getElementById("demo2").innerHTML.replace(/MICROSOFT/i,"W3Schools");
}
function troubleshooting() {
const a = 1;
const b = 1;
let result;
// Edit between these lines
// =================================
result = a + b;
// =================================
document.getElementById("demo3").innerHTML = result
}
</script>
<p>end of script</p>
</body>
</html>