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.
-
15:17
Scammer Payback
4 days agoScammer's Reaction after being Hacked
66.4K78 -
1:26:11
Michael Franzese
1 day agoMichael Franzese LIVE! | Biden Cover Up and The Power of Second Chances | Ep. 10
54.3K128 -
59:08
UFC - Ultimate Fighting Championship
3 days agoGeorges St-Pierre, Payton Talbott, UFC 303 recap | UFC Unfiltered
73.3K21 -
2:12:05
Tactical Advisor
10 hours agoGun Giveaway Info & New Build Spotlight - Vault Room Live Stream - Vault Room Live Stream
59.7K21 -
1:15:27
JoBlo Originals
1 day agoFriday Night Flicks!
66.3K11 -
1:00:41
Trumpet Daily
1 day ago $6.79 earnedJoe Biden’s Demeanor Is ‘Not of This Earth’ - Trumpet Daily | July 5, 2024
85.5K102 -
12:05
Space Ice
1 day agoStar Wars The Acolyte Is So Good The Fans Failed The Critics - Best Movie Ever
78.4K102 -
30:57
Degenerate Plays
1 day ago $2.03 earnedDid Gaming Peak Back Then? - Stellar Blade : Part 6
80.9K1 -
8:03
Kicking Mustang
1 day ago $1.68 earnedUsing my Ghillie Suit to Sneak Attack Clueless Enemies..
73.8K17 -
2:47
Maicy Renee
1 day agoSounds Like a Terrible Night!
62.8K30