HTML DOM Methods

Example 1: Changing text with getElementById()

This text will change when you click the button.

Example 2: Changing text with querySelector()

This text will change when you click the button.

Example 3: Add an item to a list with createElement() and appendChild()

Example 4: Removing an item from a list with removeChild()

Example 5: Replacing an item in a list with replaceChild()

Example 6: Insert an item before another in a list with insertBefore()

Example 7: Remove placeholder text with removeAttribute()