forked from javascript-tutorial/bn.javascript.info
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.html
56 lines (51 loc) · 1.06 KB
/
index.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
<!DOCTYPE HTML>
<html>
<body>
<ul>
<li>Animals
<ul>
<li>Mammals
<ul>
<li>Cows</li>
<li>Donkeys</li>
<li>Dogs</li>
<li>Tigers</li>
</ul>
</li>
<li>Other
<ul>
<li>Snakes</li>
<li>Birds</li>
<li>Lizards</li>
</ul>
</li>
</ul>
</li>
<li>Fishes
<ul>
<li>Aquarium
<ul>
<li>Guppy</li>
<li>Angelfish</li>
</ul>
</li>
<li>Sea
<ul>
<li>Sea trout</li>
</ul>
</li>
</ul>
</li>
</ul>
<script>
let lis = document.getElementsByTagName('li');
for (let li of lis) {
// সকল লিস্টকে গণনা <li> below this <li>
let descendantsCount = li.getElementsByTagName('li').length;
if (!descendantsCount) continue;
// মানটি লিখা
li.firstChild.data += ' [' + descendantsCount + ']';
}
</script>
</body>
</html>