applying an event handler to newly created objects

后端 未结 3 1923
星月不相逢
星月不相逢 2021-01-29 03:14

So my goal is to have 5 boxes and every time one box is clicked a new box appears. The code I wrote for that is this:

window.onload = function(){
    var boxLis         


        
3条回答
  •  灰色年华
    2021-01-29 03:25

    You will need to add an onclick event to your newly added box.

    box.onclick = clickHandler;

提交回复
热议问题