我有一个包含几个包含字符串的对象组成的数组。我能够成功利用来显示阵列:JavaScript onClick()显示
<td><p onclick="theMiddle(this)">The Middle</td>
正如你从TD标签看到,这是一个表的一部分。问题在于浏览器打开了一个新页面来显示我的文本。我一直试图在p标签中显示我的表格上方的数组。
//JavaScript
var arrayTheMiddle = new Array (showName.theMiddle, beginingTime.theMiddle,
network.abc, duration.thirty, rating.general, description.theMiddle, showImage.theMiddle);
function theMiddle(obj){
for(i=0; i < arrayTheMiddle.length; i++)
{
document.write(arrayTheMiddle[i] + "<br>");
}
}
//HTML File
<p>Would like the array/function displayed here while the user clicks within the table below (entire table has not been listed)</p>
<td><p onclick="theMiddle(this)">The Middle</td>
不幸的是,我不断地利用get元素的id来调用我的函数,它由一个数组组成。我寻找各种各样的东西,但坦率地说我迷路了。甚至不知道我的方法在这一点上是否正确。我敢肯定,这是那些简单的事情,正在我的头上!
document.appendChild? –
是否在您的html中描述了“<!DOCTYPE .......”? –
谢谢Eicto我会试试! – junaidkaps