<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script type="text/javacsript">
function showMenu(thisa) {
thisa.style.height = "180px";
}
function hideMenu(thisa) {
thisa.style.height = "30px";
}
</script>
<div onmouseover='showMenu(this)' onmouseout='hideMenu(this)' style='width:120px;height:30px;border:1px solid blue;overflow:hidden;background:#cccccc'>
<table>
<tr>
<td>下拉菜单</td>
</tr>
<tr>
<td>菜单一</td>
</tr>
<tr>
<td>菜单二</td>
</tr>
<tr>
<td>菜单三</td>
</tr>
<tr>
<td>菜单四</td>
</tr>
<tr>
<td>菜单五</td>
</tr>
</table>
</div>
</body>
</html>
<script type="text/javacsript">
javascript打错了。。type可以省略不写的
改成<script type="text/javacsript">或<script>
改背景色用backgroundColor,示例如下
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
function showMenu(thisa) {
thisa.style.height = "180px";
thisa.style.backgroundColor='#f00'
}
function hideMenu(thisa) {
thisa.style.height = "30px";
thisa.style.backgroundColor = '#cccccc'
}
</script>
<div onmouseover='showMenu(this)' onmouseout='hideMenu(this)' style='width:120px;height:30px;border:1px solid blue;overflow:hidden;background:#cccccc'>
<table>
<tr>
<td>下拉菜单</td>
</tr>
<tr>
<td>菜单一</td>
</tr>
<tr>
<td>菜单二</td>
</tr>
<tr>
<td>菜单三</td>
</tr>
<tr>
<td>菜单四</td>
</tr>
<tr>
<td>菜单五</td>
</tr>
</table>
</div>
</body>
</html>
单击鼠标改变背景颜色,是改变页面的背景还是table的颜色?
您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~
如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~
ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632