所以,我是一個HTML初學者,並且想知道是否可以做下面我想做的事情。它正在崩潰,但我不確定是唯一的原因是我的語法,還是根本不可能。調用引用的多個函數(theID)
函數的聲明:
<!-- Copyright 2005, Sandeep Gangadharan -->
<!-- For more free scripts go to http://www.sivamdesign.com/scripts/ -->
if (document.getElementById) {
document.writeln('<style type="text/css"><!--')
document.writeln('.texter {display:none} @media print {.texter {display:block;}}')
document.writeln('//--></style>') }
function close(theID) {
if (document.getElementById(theID).style.display == "block") { document.getElementById(theID).style.display = "none" } }
function open(theID) {
if (document.getElementById(theID).style.display == "block") { document.getElementById(theID).style.display = "none" }
else { document.getElementById(theID).style.display = "block" } }
// -->
</script>
</head>
使用的功能:
<table>
<tbody>
<tr>
<td colspan="2" rowspan="0">
<div>• <a href="/tallwalls/" target="_blank"><b>Tall Walls Sizer</b></a></div>
<p onClick="open('a4'), close('a1','a2','a3')" style="cursor:hand; cursor:pointer">
<span style="color: #808080;">[Click here for more information]</span></p>
</td>
</tr>
<tr id="a4" class="texter">
<td style="padding:0px;width:210px;"><a href="/tallwalls/" target="_blank" title="Tall Walls Sizer"><img src="/images/logos/tallWALLS.gif" alt="" width="206" height="41"/></a></td>
<td>
<div>DESCRIPTION</div>
</td>
</tr>
</tbody>
</table>
主要的onClick =「打開( 'A4'),接近( 'A1', 'a2','a3')「是我不確定這是否正確的語法。
編輯:忘了提,那其他ID確實存在。它們是由同樣的模式X4提前
感謝,
SirKaydian
他們需要用分號分隔。它就像JS中的其他地方一樣。陳述應以分號結尾。你只有一個'close()'的參數,但是你傳入了3個東西。不會崩潰,但你不會有任何訪問a2或a3的東西 – sachleen 2012-08-01 19:57:01
所以我會說:close('a1');關閉(A2);接近(A3)?沿着這些線? – 2012-08-01 19:59:00
這將工作。或者你可以傳遞一個數組並遍歷函數 – sachleen 2012-08-01 20:00:37