Javascript和<table>实现的简单、高效的下拉式菜单(附代码)
只需要两行javascript代码,和一个<table>就可以了,感觉CSS的比较复杂,当初把我都弄晕了,最近,静下心想了一下,发现这个很简单的方法实现。代码在二楼。
<html>
<head>
<script type="text/javascript">
function list_menu() { document.getElementById('second_1').style.display = "block" };
function hid_menu() { document.getElementById('second_1').style.display = "none" };
</script>
<title>drop menu</title>
</head>
<body>
<table width=200px; style="position:absolute; top:79px; left:100px;" >
<tr style="background-color:#999;" >
<td>first</td>
<td onmouseover="javascript:list_menu();" onclick="javascript:hid_menu();">second</td>
</tr>
<tr>
<td>
</td>
<td align="left" onmouseover="javascript:list_menu();" onmouseout="javascript:hid_menu(); " >
<div id="second_1" style="display:none; background-color:#F9F9F9">
<a href="#">1st</a><br>
<a href="#">2nd</a><br>
<a href="#">3rd</a><br>
</div>
</td>
</tr>
</table>
</body>
</html>