0

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

5
  • Make sure you insert/append the element to the page. Commented Sep 16, 2013 at 12:58
  • @Jeffman, there is no need to append it first Commented Sep 16, 2013 at 12:59
  • When OP said it didn't work, I assumed he saw no evidence. Not appending it could be a reason. Commented Sep 16, 2013 at 13:00
  • @Jeffman, or the reason is invalid code. ;) Commented Sep 16, 2013 at 13:02
  • Sounds like you'll swim easier with jQuery: $("#arrowBase").html("hello"); Commented Sep 16, 2013 at 13:03

2 Answers 2

6

Read the docs, it is not a method.

arrowBase.innerHTML = 'hello';
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

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.