0

I have a div:

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

And now I would like to create table there, where will be placed things from Js array. I tried this:

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

But it doesn't work :/

Uncaught TypeError: Property 'innerHTML' of object # is not a function

3 Answers 3

3

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

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

More information at MDN.

Sign up to request clarification or add additional context in comments.

Comments

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 :)

Comments

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>';

2 Comments

Actually it doesn't matter what you pass in as long as you use it like a property and not like a function call.
Yes, it's like ordinary property of object

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.