When I click start
,some choices will be displayed.
I would like to select each choice by getElementById
is it possible?
How can I change my work to achieve it ?
Thanks
document.getElementById("start").addEventListener('click',function(){
html=" ";
for (let i=1;i<=4; i++){
html+= "<button id='choice'>"+"choice"+i+"</button><br>";
}
document.querySelector('.btn').innerHTML = html;
});
document.getElementById("choice").addEventListener('click',function(){
console.log(this);
});
<div class ="btn"><button id="start">start</button></div>