55
rated 0 times
[
60]
[
5]
/ answers: 1 / hits: 27994
/ 9 Years ago, sat, january 23, 2016, 12:00:00
i want to insert a htmlsnippet into another html-element
i tried it this way
the html
<div class=box1>
insert this html element
</div>
<div class=box2>
into this
</div>
the js
var box1 = document.querySelectorAll(.box1)[0];
var box2 = document.querySelectorAll(.box2)[0];
console.log(box1);
box2.innerHTML = box1;
but it doesnt work it only insert [object HTMLDivElement], if i look at the console it puts out the correct html, what im doing it wrong?
and yeah i dont want to use the $ libary ;)
http://codepen.io/destroy90210/pen/MKQOwy
thanks ;)
More From » innerhtml