Javascript: Accessing and modifying DOM elements

This entry is part 24 of 27 in the series Javascript Tutorial

Below are some common methods that we use to access and modify HTML DOM elements.

Accessing HTML Elements

MethodDescription
document.getElementById()Finding an element by element id
document.getElementsByTagName()Finding elements by tag name
document.getElementsByClassName()Finding elements by class name
document.getElementsByName()Finding elements by name

Changing HTML Elements

MethodDescription
document.getElementById(id).innerHTML=Changing the inner HTML of an element
document.getElementById(id).attribute=Changing the attribute of an element
document.getElementById(id).style.attribute=Changing the style of an HTML element
Series Navigation<< Javascript: HTML DOM
Javascript: Events >>