0
0
Fork 0
Weighted-RNG/js/add_choice.js
2019-09-10 17:52:47 -06:00

12 lines
No EOL
458 B
JavaScript

const add_choice = () => {
let index = document.getElementsByClassName("choice").length;
let choice_div = document.getElementById("choice-template");
let clone = choice_div.content.cloneNode(true);
clone.childNodes[1].childNodes[1].id = `text-in-${index}`;
clone.childNodes[1].childNodes[3].id = `weight-in-${index}`;
// Add to document without resetting the other ones
document.getElementById("choices").appendChild(clone);
};