-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
30 lines (24 loc) · 1.13 KB
/
script.js
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
console.log(document.getElementsByTagName("li").length);
console.log(document.querySelectorAll("#onbed li").length);
console.log(document.querySelectorAll("#offbed li").length);
function count1Function() {
const value = document.getElementsByTagName("li").length;
document.getElementById("result1").innerHTML = `There are ${value} tasks for morning routine. (There are ${value} list tags on this page.) `;
}
function count2Function() {
const value = document.querySelectorAll("#onbed li").length;
document.getElementById("result2").innerHTML = `There are ${value} tasks on the bed. (There are ${value} elements inside the first ID.) `;
}
function count3Function() {
const value = document.querySelectorAll("#offbed li").length;
document.getElementById("result3").innerHTML = `There are ${value} tasks off the bed. (There are ${value} elements inside the second ID. `;
}
document.getElementById('count1').addEventListener('click', e => {
count1Function();
})
document.getElementById('count2').addEventListener('click', e => {
count2Function();
})
document.getElementById('count3').addEventListener('click', e => {
count3Function();
})