โ Back to HTML DOM
Question 147
Count List Items
Count List Items
Count how many<li>items are inside the list with id="list" and show that number (3) as the text of the paragraph with id="count". Platform-Provided HTML (READ-ONLY): <div id="app"> <ul id="list"> <li>A</li> <li>B</li> <li>C</li> </ul> <p id="count"></p> </div> Steps: 1. Readlist.children.lengthto count the list items. 2. Assign that number to thetextContentof#count.
Expected Output:
<div id="app">
<ul id="list">
<li>A</li>
<li>B</li>
<li>C</li>
</ul>
<p id="count">3</p>
</div>Topics:
HTML DOM
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (clog, fn, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.