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>


Weiter lernen
||
<!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>
einreichenCode zurücksetzen