为什么下面的javascript函数不能被调用

来源:百度知道 编辑:UC知道 时间:2024/06/01 17:18:35
<html>
<head>
<script type="text/javascritp">
function showandhide(id){
var oTrow = document.getElementById(id);
if(oTrow.style.display){
oTrow.stytle.display="";
return;
}
oTrow.style.display="none";
}
</script>
</head>
<body>
<table>
<tbody>
<tr ><td><a href="javascript:void(0)" onclick="showandhide('dept1')">部门1</a></td></tr>
<tr id="dept1" style="display:">
<td>
<table>
<tbody>
<tr><td>人员1</td></tr>
<tr><td>人员1</td></tr>
</tbody>
</table>
</td>
</tr>

</tbody>
</table>
</body>
</html>
不好用啊?我的目的是点击部门1会出现员工,再次点击会隐藏

<a href="javascript:void(0)" onclick="showandhide('dept1')">部门1</a>

通常不要两个都是js语句
前一个 href="#" 比较好..虽然前头的语句是空的,但还是很容易混淆

<tr id="dept1" style="display:">这句话错了 本来就是显示的
你JS语句控制显示 肯定没效果
应该是<tr id="dept1" style="display:none;">

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>测试</title>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<script language="javascript">
function showandhide(n)
{
var oTrow = document.getElementById(n);

if(oTrow.style.display=='none')
{oTrow.style.display='';}