Как мне сделать так, чтобы при вводе ввода я все равно мог ввести другой ввод позже без необходимости перезагрузки
Вот почему я спрашиваю, можно ли зациклить событие щелчка и будет ли оно работать в этой ситуации.
Буду признателен за любые советы.
Код: Выделить всё
const container = document.getElementById("container");
const input = document.getElementById("btn");
const inputNew = document.getElementById("input");
function makeDivs(numDivs) {
for (let d = 0; d < numDivs; d++) {
let cells = document.createElement("div");
container.appendChild(cells)
}
}
makeDivs(256);
input.addEventListener("click", () => {
let inputReceived = prompt("Number of squares you need");
const element = document.getElementById("container");
element.remove();
userInput(inputReceived);
});
function userInput(numInput) {
for (let i = 0; i < numInput; i++) {
let cells = document.createElement("div");
inputNew.appendChild(cells)
element = document.getElementById("input");
element.classList.add("new");
}
}Код: Выделить всё
Input Number
Подробнее здесь: https://stackoverflow.com/questions/798 ... lick-event
Мобильная версия