Get the li count of a specific ul in javascript
Created at 04-Jul-2022 ,
By samar
Get the li count of a specific ul in javascript
In this article, we will see how to solve "Get the li count of a specific ul in javascript".
I want to get the count of all LI (List item) of a specific UL in Javascript. How can i get the count of the all list item by targeting an unordered list of HTML.-
<ul id="ul_list"> <li>Lorem ipsum dolor sit amet consectetuer.</li> <li>Aenean commodo ligula eget dolor.</li> <li>Aenean massa cum sociis natoque penatibus.</li> </ul> <script> var listCount = document.getElementById("ul_list").getElementsByTagName("li").length; alert(listCount); </script>
It will return the count of all (LI) items of an UL.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Javascript
- Prism js horizontally overflowing its container
- How to show and hide placeholder text
- How to check file is an image in javascript using filename
- How to validate empty space in textbox in Javascript
- Javascript to print Fibonacci series upto 15 Observations
- How to add a property to object with condition in javascript
- Javascript set timeout function with example code
- How to get the length of a number in JavaScript
- Get hostname from URL in javascript
- How to display for slash as a string in javascript HTML
- Execute function with condition in javascript
- Concat variable with string in javascript
- How to switch between Dark Mode and Light Mode based on cookie in Javascript
- Uncaught SyntaxError: Identifier 'CODE' has already been declared
- Short-circuits conditionals
- How to open modal after redirect
- Trim the leading and trailing comma from string in Javascript
- Uncaught TypeError: Assignment to constant variable
- JavaScript test() Method
- How to validate input type file size in javascript
- How to preview a word document in HTML using javascript
- Uncaught TypeError: $(...).summernote is not a function
- How to echo array in Javascript
- How to check caps lock is on in javascript
- Remove property from object in javascript