appendChild

Introduction to the JavaScript appendChild() method The appendChild() is a method of the Node interface. The appendChild() method allows you to add a node to the end of the list of child nodes of a specified parent node.…

Continue ReadingappendChild

CreateElement

To create an HTML element, you use the document.createElement() method: let element = document.createElement(htmlTag); The document.createElement() accepts an HTML tag name and returns a new Node with the Element type. 1) Creating a new div example Suppose that…

Continue ReadingCreateElement

Getting Child Elements

Suppose that you have the following HTML fragment: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>JS Get Child Elements</title> </head> <body> <ul id="menu"> <li class="first">Home</li> <li>Products</li> <li class="current">Customer Support</li> <li>Careers</li> <li>Investors</li>…

Continue ReadingGetting Child Elements

querySelector

Introduction to JavaScript querySelector() and querySelectorAll() methods The querySelector() is a method of the Element interface. The querySelector() method allows you to select the first element that matches one or more CSS selectors. The following illustrates…

Continue ReadingquerySelector

getElementsByClassName

Introduction to the getElementsByClassName() method The getElementsByClassName() method returns an array-like of objects of the child elements with a specified class name. The getElementsByClassName() method is available on the document element or any other elements. When…

Continue ReadinggetElementsByClassName