HTML DOM Methods
Example 1: Changing text with getElementById()
This text will change when you click the button.
Change Text
Example 2: Changing text with querySelector()
This text will change when you click the button.
Change Text
Example 3: Add an item to a list with createElement() and appendChild()
Old Item
Old Item
Add List Item
Example 4: Removing an item from a list with removeChild()
Item 1
Item 2
Item 3
Remove Item
Example 5: Replacing an item in a list with replaceChild()
Item 1
Item 2
Replace Item 2
Example 6: Insert an item before another in a list with insertBefore()
Item 1
Item 2
Insert New Item Before Item 1
Example 7: Remove placeholder text with removeAttribute()
Remove Placeholder