How to insert new elements with event listeners? [duplicate]

One solution in my mind is to add a class (say myBtnEvent) to all the buttons and dynamic buttons and listen to click event at document level. Ex: Boom

document.addEventListener('click', function(event) {
    if(event.target && event.target.classList.contains('myBtnEvent')){
          //do your stuff
     }
 });