
JavaScript DOM Manipulation Cheatsheet!
Creating elements:
Use document.createElement(tagName) to create a new HTML element.
Removing elements:
Use element.remove() or parentElement.removeChild(element) to delete an element from the DOM.
Querying elements:
Use document.querySelector(selector) or document.querySelectorAll(selector) to find elements in the DOM.
Modify elements:
Use element.innerHTML or element.textContent to change the content of an element.
Modifying the class:
Use element.classList.add(className), element.classList.remove(className), or element.classList.toggle(className) to change an element's classes.
Modifying the text:
Use element.textContent to set or get the text content of an element.
Modifying the attribute in general:
Use element.setAttribute(name, value) or element.getAttribute(name) to set or get an element's attributes.
Like, Share and Subscribe #DevTools99 for more useful videos, tools info and #tutorials . Thank you!