如下所示;
复制代码代码如下:
<! 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">
<голова>
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<title> 无标题文档 </title>
<script type = "text/javascript">
function change_bg (obj)
{
var a = document.getElementbyId ("меню"). getElementsbytagname ("a");
для (var i = 0; i <a.length; i ++)
{
a [i] .classname = "";
}
obj.classname = "current";
}
</script>
<стиль типа = "text/css">
тело{
размер шрифта: 17px;
}
.текущий{
Фон: красный;
}
#container ul
{
тип списка: нет;
}
#container ul li
{
Плавание: осталось;
Право маржи: 3PX;
}
#container ul li a {
Текстовое декорация: нет;
Цвет:#000;
}
</style>
</head>
<тело>
<div id = "контейнер">
<ul id = "menu">
<li> <a href = "javascript:" onclick = "change_bg (this)"> menu1 </a> </li>
<li> <a href = "javascript:" onclick = "change_bg (this)"> menu2 </a> </li>
<li> <a href = "javascript:" onclick = "change_bg (this)"> menu3 </a> </li>
<li> <a href = "javascript:" onclick = "change_bg (this)"> menu4 </a> </li>
<li> <a href = "javascript:" onclick = "change_bg (this)"> menu5 </a> </li>
</ul>
</div>
</body>
</html>