Created
December 13, 2021 06:15
-
-
Save YasirGaji/330561450aafae17e35edaadfc8d0d27 to your computer and use it in GitHub Desktop.
This gist showcases how to remove child elements using javascript its further explained in the DOD article by Yasir Gaji
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const liElements = document.querySelectorAll('li'); // this initializes "liElements" as a variable to represent all the "li" elements in the Html collection | |
const list = document.querySelector('ul'); // this initializes "list" as a variable to represent the "ul" element in the Html collection | |
list.removeChild(liElements[3]); // THIS EXECUTES THE MAIN TASK BY TAKING OUT THE 4TH "li" ELEMENT IN THE "ul" USING THE ".removeChild()" METHOD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment