Javascript 基礎教學 DOM 與 CSS

如何使用DOM 來改變html的樣式

如下程式碼:

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>DOM 与 CSS</title>	
</head>
<body>
	<div name="dv" id="dv" width="300" height="200">php 中文网</div>

	<script type="text/javascript">
		var dv = document.getElementById("dv").style.color = "red";
	</script>
</body>
</html>


繼續學習
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>DOM 与 CSS</title> </head> <body> <div name="dv" id="dv" width="300" height="200">php 中文网</div> <script type="text/javascript"> var dv = document.getElementById("dv").style.color = "red"; </script> </body> </html>