0

我有一个 div:

<div id="bottom">
</div> 

现在我想在那里创建表,将 Js 数组中的东西放在哪里。我试过这个:

document.getElementById('bottom').innerHTML("Text");

但它不起作用:/

未捕获的类型错误:对象# 的属性“innerHTML”不是函数

4

3 回答 3

3

innerHTML is a property and no method. Use it like this:

document.getElementById('bottom').innerHTML = "Text";

More information at MDN.

于 2013-03-17T14:37:03.710 回答
1

I believe you don't need any methods as innerHTML is a property and u can use it as below

document.getElementById('bottom').innerHTML = "Text";

happy coding :)

于 2013-03-17T14:38:27.410 回答
1

You have this error becouse of innerHTML should be assigned to htmlString. Something like this:

document.getElementById('bottom').innerHTML = '<table><tr><td>Text</td></tr></table>';
于 2013-03-17T14:39:16.660 回答