I'm trying to add a button with a link after a div that has no id, using Google Tag Manager. I'm taking the specific div (without id) using the code below, but when I try to put the button after that div using innerHTML, the div is replaced by the button, and if I use appendChild (commented in my code) nothing happens.
<script>
var HTML = '<a href="#" target="_blank" class="button" >Send</a>'
var title = document.getElementsByClassName("class_title");
title[0].nextSibling.nextSibling.setAttribute("id", "newdiv");
document.getElementById("newdiv").innerHTML = HTML;
//getElementById("newscript").appendChild(HTML);
</script>
What am I doing wrong? Thanks a lot!