document.write(Date());
2.修改指定元素内容
document.getElementById("p1").innerHTML="New text!";
3.改变html属性
document.getElementById(id).属性名=new value;
举个栗子:改变img的src
<!DOCTYPE html> <html> <body> <img id="image" src="smiley.gif"> <script> document.getElementById("image").src="landscape.jpg"; </script> </body> </html>
4.改变CSS样式
document.getElementById(id).style.样式名=new style;
举个栗子:改变p2段落的颜色为blue
<p id="p2">Hello World!</p> <script> document.getElementById("p2").style.color="blue"; </script>