JavaScript DOM 学习[1]

http://www.w3schools.com/js/js_htmldom.asp

# DOM(Document Object Model)

# The document object represents your web page.

# If you want to access any element in an HTML page, you always start with accessing the document object.

# The innerHTML property can be used to get or change any HTML element, including <html> and <body>.

# document.getElementById(id)
# document.getElementsByTagName(name)
# document.getElementsByClassName(name)

# element.innerHTML =  new html content
# element.attribute = new value
# element.setAttribute(attribute, value)
# element.style = new style

<html>
<body>

<p id="demo">Hi</p>

<script>
alert(document.getElementById("demo").innerHTML);
document.getElementById("demo").innerHTML = "Hello World!";
</script>

</body>
</html>

这篇文章: 有用 无用