Premium Only Content
DOM Tutorial | Dom Manipulation in HTML| Day 37 | Part - 1 | Web development Course 2023
DOM Manipulation
DOM Manipulation refers to the process of dynamically changing the content, structure, and style of a web page after it has loaded. This is done by accessing and manipulating the Document Object Model (DOM), which is a tree-like representation of the HTML document.
There are several ways to manipulate the DOM in JavaScript:
1. Accessing DOM elements:
getElementById: Retrieves an element by its unique ID.
getElementsByClassName: Retrieves a collection of elements by their class name.
getElementsByTagName: Retrieves a collection of elements by their tag name.
querySelector: Retrieves the first element that matches a CSS selector.
querySelectorAll: Retrieves a collection of elements that match a CSS selector.
2. Modifying content:
textContent: Sets or gets the text content of an element.
innerHTML: Sets or gets the HTML content of an element.
innerText: Sets or gets the inner text of an element (including any child elements).
3. Modifying attributes:
setAttribute: Sets an attribute on an element.
getAttribute: Gets the value of an attribute on an element.
removeAttribute: Removes an attribute from an element.
4. Adding and removing elements:
appendChild: Adds a child element to the end of another element.
insertBefore: Adds a child element before another child element.
removeChild: Removes a child element from its parent element.
5. Modifying styles:
style.setProperty: Sets the value of a specific style property.
classList.add: Adds a class name to an element.
classList.remove: Removes a class name from an element.
-
LIVE
Redacted News
1 hour agoBREAKING! DEMS PLAN TO BLOCK TRUMP FROM INAUGURATION, BIDEN TO RESIGN TO INSTALL HARRIS | REDACTED
20,072 watching -
4:10
SLS - Street League Skateboarding
1 day agoJhank Gonzalez 4th Place SLS Sydney 2024 | Best Tricks
10.3K -
1:12:52
Steve-O's Wild Ride! Podcast
11 days ago $1.51 earnedJay Mewes Is Using DNA Testing To Find His Family - Wild Ride #241
8.93K2 -
1:02:32
Criminal Content
1 day agoWITNESS (1985) Movie Reaction w/ Coby FIRST TIME WATCHING
611 -
1:01:45
In The Litter Box w/ Jewels & Catturd
1 day agoNo RINOs, Neocons, or Warhawks! | In the Litter Box w/ Jewels & Catturd – Ep. 688 – 11/11/2024
55.3K -
2:27:37
The Black and Jewish Podcast with Ashira Solomon
3 months agoEp. 3 Christians Are Biblically Illiterate
13.4K13 -
1:53:43
The Quartering
5 hours agoKamala's Desperate Attempt To Stop Trump & Installed As President! House Race Update New Border Czar
97.5K18 -
1:27:19
Russell Brand
6 hours agoKamala Goes BANKRUPT & WARS w/Biden + President Trump Announces Plan To RECLAIM Free Speech - SF490
219K243 -
11:32
Silver Dragons
3 hours agoIs This GAME OVER for SILVER?
16.7K5 -
9:04
Gun Owners Of America
1 day agoTrump Promises To "Rip Up" ATF Rules
13K15