I have 6 'like' buttons, clicking on which, counter increase. How can i use event handler on all 'like' buttons. In my example only the last one is working.
constructor(model) {
this.count = 0;
for(let i = 0; i < 6; i++){
this.renderInitialTodoForm();
}
this.likeButton.addEventListener('click', () => {
this.count++;
this.likeCount.innerHTML = this.count;
})
}
renderInitialTodoForm = () => {
this.app = this.getElement('#root');
this.likeButton = this.createElement('span', 'likeImg');
this.likeButton.textContent = '';
this.likeCount = this.createElement('span', 'like');
this.likeCount.textContent = 0;
this.app.append( this.likeButton, this.likeCount);
};