td er ikke et block element ...
eksempler ... dette virker ikke i IE, men mest korrekt da tr er en table-row:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd"><head><meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<script language="javascript">
function ActivateMenu(img,id)
{
e = document.getElementById(id);
if(e.style.display == "none")
{
e.style.display = "table-row";
img.src = "bullet_arrow_up.png";
}
else
{
e.style.display = "none";
img.src = "bullet_arrow_down.png";
}
}
</script>
</head><body>
<table cellpadding="0" cellspacing="0" class="menu_item">
<tr>
<td class="heading">
<img style="cursor:pointer;" onclick="ActivateMenu(this, 'menu_1');" src="bullet_arrow_up.png" alt="midlertidig alt"> Menu heading
</td>
</tr>
<tr id="menu_1">
<td class="content">
Menupunkt 1<br />
Menupunkt 2<br />
Menupunkt 3<br />
Menupunkt 4<br />
</td>
</tr>
</table>
</body></html>
virker i IE og FF:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd"><head><meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<script language="javascript">
function ActivateMenu(img,id)
{
e = document.getElementById(id);
if(e.style.display == "none")
{
e.style.display = "block";
img.src = "bullet_arrow_up.png";
}
else
{
e.style.display = "none";
img.src = "bullet_arrow_down.png";
}
}
</script>
</head><body>
<table cellpadding="0" cellspacing="0" class="menu_item">
<tr>
<td class="heading">
<img style="cursor:pointer;" onclick="ActivateMenu(this, 'menu_1');" src="bullet_arrow_up.png" alt="midlertidig alt"> Menu heading
</td>
</tr>
<tr id="menu_1">
<td class="content">
Menupunkt 1<br />
Menupunkt 2<br />
Menupunkt 3<br />
Menupunkt 4<br />
</td>
</tr>
</table>
</body></html>
alternativet:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd"><head><meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<script language="javascript">
function ActivateMenu(img,id)
{
e = document.getElementById(id);
if(e.style.display == "none")
{
e.style.display = "block";
img.src = "bullet_arrow_up.png";
}
else
{
e.style.display = "none";
img.src = "bullet_arrow_down.png";
}
}
</script>
</head><body>
<table cellpadding="0" cellspacing="0" class="menu_item">
<tr>
<td class="heading">
<img style="cursor:pointer;" onclick="ActivateMenu(this, 'menu_1');" src="bullet_arrow_up.png" alt="midlertidig alt"> Menu heading
</td>
</tr>
<tr>
<td class="content"><div id="menu_1">
Menupunkt 1<br />
Menupunkt 2<br />
Menupunkt 3<br />
Menupunkt 4<br />
</div></td>
</tr>
</table>
</body></html>