'How to add a value between a dom element?

This is my element:

<var mathquill-command-id="56"></var>

I want to add something between like this:

<var mathquill-command-id="56">HERE</var>

This is my process so far:

const p = document.createElement('var')
p.setAttribute('mathquill-command-id', '56')
this.p.value = 'HERE'
this.main.append(p)

this.main is the parent element.

But it looks like .value does not work. I got the idea to use .value from how textbox element works.



Solution 1:[1]

element.value can only be used on input Element,so you shoud use p.innerHtml or p.innerText

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mengwenR