How to select all li at once using JavaScript
JavaScript DOM Manipulation (Article) DOM Manipulation (Program)
125Program:
<!DOCTYPE html> <html> <body> <ul> <li> Hello </li> <li> Hello </li> <li> Hello </li> <li> Hello </li> <li> Hello rumman </li> </ul> </body> </html> <!- Script Code --> <script> let elementLi = document.getElementsByTagName('li'); Array.from(elementLi).forEach(element =>{ console.log(elementLi); element.style.color = 'blue'; element.style.boxShadow = '2px 5px #888888'; element.style.border = '1px solid'; element.style.padding = '10px'; }); </script>
Output:
Copy above code and run it in your environment to see the output.
Explanation:
No
This Particular section is dedicated to Programs only. If you want learn more about Javascript. Then you can visit below links to get more depth on this subject.