add button to delete trait

This commit is contained in:
Thomas Rubini 2023-03-18 19:03:31 +01:00
parent a945eb9f6b
commit 8451100415
No known key found for this signature in database
GPG Key ID: C7D287C8C1CAC373

View File

@ -7,6 +7,7 @@
<input class="name_input" value="{{trait['name']}}">
<p> Description: </p>
<input class="desc_input" value="{{trait['desc']}}">
<button onclick="deleteTrait(this)">Delete trait</button>
</section>
{%endfor%}
</section>
@ -26,6 +27,11 @@ function addNewInput(){
traits.appendChild(newTrait);
}
function deleteTrait(buttonNode){
let traitNode = buttonNode.parentNode;
traitNode.parentNode.removeChild(traitNode);
}
function saveForm(){
let data = [];
for(let section of traits.querySelectorAll("section")){