im trying to have a button that when clicked will clone the parent of the buttons parent and append to the body.
<div class="userposts">
<p class="postusername">Posted by $postuser</p>
<script type="text/javascript">
function click() {
var div = this.parentElement.parentElement;
var clone = div.cloneNode(true);
document.body.appendChild(clone);
}
</script>
<h2 class="posttitle"><button onclick="click()" type="button">$title<button></a></h2>
This is what I have so far but It doesn't append anything nor does it leave any error messages. Thanks.
Aucun commentaire:
Enregistrer un commentaire