I am working on a javascript file and have code like following
class test(){
constructor(){
}
showBox(){
var countBlock = document.createElement("div");
document.body.appendChild(countBlock);
countBlock.addEventListener('click', function(){
this.showList()
});
}
showList(){
console.log('Element clicked')
}
}
Code is working fine unless I click on element, when I click it shows this.showList() is not a function
Not sure how to resolve it