I created a bit of HTML in a template tag that I want to use from time to time in my webpage. I can get it to display once no problem, but if I try to add it elsewhere in the page it does not show up. I have included a much simplified version of the code below. Can someone enlighten me as to what I’m doing wrong?
var template = document.getElementById('testtemplate').content;
document.getElementById('firstDiv').appendChild(template);
document.getElementById('secondDiv').appendChild(template);
<template id='testtemplate'>
<div class = calendarcontainer>
<h1>hello</h1>
</div>
</template>
<div id='firstDiv'></div>
<div id='secondDiv'></div>