如下所示;
复制代码代码如下:
<! doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<title> 无标题文档 </title>
<script type = "text/javascript">
ฟังก์ชั่น Change_bg (obj)
-
var a = document.getElementById ("เมนู"). getElementsByTagname ("A");
สำหรับ (var i = 0; i <a.length; i ++)
-
A [i] .className = "";
-
obj.className = "ปัจจุบัน";
-
</script>
<style type = "text/css">
ร่างกาย{
ขนาดตัวอักษร: 17px;
-
.ปัจจุบัน{
ความเป็นมา: สีแดง;
-
#container ul
-
ประเภทรายการประเภท: ไม่มี;
-
#container ul li
-
ลอย: ซ้าย;
มาร์จิ้น-ขวา: 3px;
-
#Container ul li a {
การตกแต่งข้อความ: ไม่มี;
สี:#000;
-
</style>
</head>
<body>
<div id = "container">
<ul id = "เมนู">
<li> <a href = "javascript:" onclick = "change_bg (นี่)"> menu1 </a> </li>
<li> <a href = "JavaScript:" onclick = "Change_bg (นี่)"> menu2 </a> </li>
<li> <a href = "javascript:" onclick = "change_bg (นี่)"> menu3 </a> </li>
<li> <a href = "JavaScript:" onclick = "Change_bg (นี่)"> เมนู 4 </a> </li>
<li> <a href = "JavaScript:" onclick = "Change_bg (นี่)"> เมนู 5 </a> </li>
</ul>
</div>
</body>
</html>