Home > Enterprise >  How to add a value between a dom element?
How to add a value between a dom element?

Time:05-20

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.

CodePudding user response:

Do something like this:

p.innerHTML = 'HERE'

CodePudding user response:

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

  • Related