[問題] 關於div的顯示與隱藏
目前我是這樣寫得:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"" rel="nofollow">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="" rel="nofollow">http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文件</title>
<style type="text/css">
<!--
.div001 {
visibility: hidden;
}
-->
</style>
<script type="text/javascript">
<!--
function MM_showHideLayers() { //v9.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3)
with (document) if (getElementById && ((obj=getElementById(args[i]))!=null))
{ v=args[i+2];
if (obj.style) { obj=obj.style;
v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
obj.visibility=v; }
}
//-->
</script>
</head>
<body>
<p onclick="MM_showHideLayers('001','','show')">打開</p>
<div class="div001" id="001">test</div>
</body>
</html>
但是這樣寫有一個缺點,就是當div高度很高時,就算隱藏也會把外圍的表格撐開
於是我嘗試用 display: none; 的方式隱藏他(div預設隱藏)
然後將onClick的地方改成下面這樣
onClick="document.getElementById('001').style.display='';"
CSS的地方改成這樣:
.div001 {
visibility: hidden;
display: none;
}
不過沒有效果,點下去東西還是消失狀態...囧!
於是我把上面那句onClick改成
onClick="document.getElementById('001').style.display='inherit';
問題大部分都解決了(在Google Chrome、FireFox、Opera),
不過這樣在IE 7裡面沒用.... (/‵Д′)/~ ╧╧
這該怎麼辦呢?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.46.165.222
推
03/07 16:05, , 1F
03/07 16:05, 1F
→
03/07 16:05, , 2F
03/07 16:05, 2F
→
03/07 16:06, , 3F
03/07 16:06, 3F
→
03/07 16:11, , 4F
03/07 16:11, 4F
推
03/07 16:16, , 5F
03/07 16:16, 5F
→
03/07 16:18, , 6F
03/07 16:18, 6F
→
03/07 16:29, , 7F
03/07 16:29, 7F
→
03/07 16:29, , 8F
03/07 16:29, 8F
→
03/08 14:47, , 9F
03/08 14:47, 9F