I have a project, but for it to work I need to refresh the page every time I create a new element. The problem is that when I refresh the page it also deletes the created dom elements. Is there a way to reload everything but keep the dom elements until you refresh te page yourself?
function BTN() {
for (let i = 0; i < 7; i++) {
let btn = document.createElement('button');
btn.classList.add('btn')
btn.id = 'Button' + i
btn.innerHTML = 'Button' + i;
document.getElementsByClassName('Btns')[0].appendChild(btn);
}
}
document.getElementsByClassName('QPB')[0].addEventListener('click', () => {
BTN()
})
.btn {
width: 100px;
height: 50px;
background-color: red;
margin-right: 10px;
}
.QPB {
width: 50px;
height: 50px;
margin-bottom: 10px;
background-color: orange;
}
<Button class="QPB">+</Button>
<div class="Btns">
</div>
So I need to refresh the page but not delete all elements. Is there a way to do it?