实现下拉菜单
<!DOCTYPE html>
<html>
<head>
<title>下拉菜单示例</title>
<script language="javaScript">
//当鼠标移动到菜单选项的时候显示对应的DIV
function show(menu){
document.getElementById(menu).style.visibility="visible";}
//当鼠标移出的时候隐藏所有的DIV
function hide(){
document.getElementById("menu1").style.visibility="hidden";
document.getElementById("menu2").style.visibility="hidden";
document.getElementById("menu3").style.visibility="hidden";
}
</script>
</head>
<body>
<table>
<tr bgcolor="#9999FF" align="center">
<td width="120" onMouseMove="show('menu1')" onMouseOut="hide()">系列课程</td>
<td width="120" onMouseMove="show('menu2')" onMouseOut="hide()">教学课件</td>
<td width="120" onMouseMove="show('menu3')" onMouseOut="hide()">课程大纲</td>
</tr>
</table>
<div id="menu1" onMouseMove="show('menu1')" onMouseOut="hide()"
style="background:#9999FF;position:absolute;left:12px;top:38px;width:120px;
visibility=hidden">
<span>c++程序设计</span><br>
<span>java程序设计</span><br>
<span>c#程序设计</span><br>
</div>
<div id="menu2" onMouseMove="show('menu2')" onMouseOut="hide()"
style="background:#9999FF;position:absolute;left:137px;top:38px;width:120px;
visibility=hidden">
<span>c++课件</span><br>
<span>java课件</span><br>
<span>c#课件</span><br>
</div>
<div id="menu3" onMouseMove="show('menu3')" onMouseOut="hide()"
style="background:#9999FF;position:absolute;left:260px;top:38px;width:120px;<!--注意是:,以及px-->
visibility=hidden">
<span>c++教学大纲</span><br>
<span>java教学大纲</span><br>
<span>c#教学大纲</span><br>
</div>
</body>
</html>
实现表格变色
<!DOCTYPE html>
<html>
<head>
<title>变色表格示例</title>
<script language="javaScript">
function changeColor(row){
document.getElementById(row).style.backgroundColor='#CCCCFF';
}
function resetColor(row){
document.getElementById(row).style.backgroundColor='';
}
</script>
</head>
<body>
<table width="200" border="5" cellpadding="1" align="center"><!-- cellpadding规定单元边沿与其内容之间的空白,实际上就是格子里面空白部分的多少 -->
<tr><th>学校</th><th>专业</th><th>人数</th></tr>
<tr align="center" id="row1"
onMouseOver="changeColor('row1')" onMouseOut="resetColor('row1')">
<th>北大</th><th>法律</th><th>2000</th>
</tr>
<tr align="center" id="row2"
onMouseOver="changeColor('row2')" onMouseOut="resetColor('row2')">
<th>清华</th><th>计算机</th><th>5000</th>
</tr>
<tr align="center" id="row3"
onMouseOver="changeColor('row3')" onMouseOut="resetColor('row3')">
<th>人大</th><th>经济</th><th>6000</th>
</tr>
</table>
</body>
</html>