Marc
Marc

Reputation: 493

Javascript create element and add HTML

say for instance i have the following line:

        var arrowBase = document.createElement('div')

Now within this div tag i want to add some HTML (i.e text).

Then i tried the following:

arrowBase.innerHTML('hello');

However this does nothing:S

i have also tried: arrowBase.HTML('hello');

But once again without any result

I know is that rather simple but in my search i could'nt find the answer hope someone is able to help me out here

Upvotes: 0

Views: 78

Answers (2)

Annamalai Nagappan
Annamalai Nagappan

Reputation: 509

arrowBase.textContent = "HELLO"

also does the same thing but only text can be specified. Whereas in innerHTML html tags can be specified along with the text.

Upvotes: 0

epascarello
epascarello

Reputation: 207511

Read the docs, it is not a method.

arrowBase.innerHTML = 'hello';

Upvotes: 6

Related Questions