Tutorial Asas J...LOGIN

Tutorial Asas Javascript: DOM dan CSS

Cara menggunakan DOM untuk menukar gaya html

Kod berikut:

<!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>


bahagian seterusnya
<!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>
babperisian kursus