I’m trying to grab some simple html and put into another DIV, but all i get back is [object HTMLDivElement]
, What am i doing wrong here?
this.inner = document.querySelector('div[data-v="1"]')
this.tail = document.querySelector('[data-tail]')
this.tail.innerHTML = this.inner
<div data-tail></div>
<div data-v="1">some content</div>
3
Answers
Add
.innerHTML
to get the content.document.querySelector('div[data-v="1"]')
refers to the objectCheck this documentation first, The Document method querySelector() returns the first Element within the document that matches the specified selector, or group of selectors. If no matches are found, null is returned.
You just have to use innerHTML properly
Change it like this
obviously you can not assign a ElementNode as HTML string.