-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcollection.html
More file actions
28 lines (26 loc) · 872 Bytes
/
collection.html
File metadata and controls
28 lines (26 loc) · 872 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
<ol>
<li class="fruit">Apple</li>
<li class="nut">Almond</li>
<li class="fruit">Apricot</li>
</ol>
<ol>
<li class="fruit">Blackberry</li>
<li id="country" class="nut">Brazil</li>
<li class="fruit">Banana</li>
</ol>
<p id="info"></p>
<script>
(function(){
const info = document.getElementById('info')
const item = document.getElementById('country')
const lists = document.getElementsByTagName('ol')
const fruits = document.getElementsByClassName('fruit')
let i = 0
info.innerHTML = item + 'Id: ' + item.innerText + '<br />'
info.innerHTML += '<br />' + lists + 'Tags: <br />'
for( i = 0 ; i < lists.length ; i++ ){
info.innerHTML += ( i + 1 ) + ' of ' + fruits.length
info.innerHTML += ': ' + fruits[ i ].innerText + '<br />'
}
})()
</script>