I have a function that dynamically generates lis and then attached addEventListener that allows users to delete the row. Do I need to removeEventListener even if delete the row already?
function li (){
var li = document.createElement('li'),
that = this;
li.addEventListener('click', function(){
that.delete(li);
}
}
On the side note, I am using an anonymous function to pass li into the function. Is there another way to do it?
No, you don’t need to call
removeEventListener.Use the below to remove self on click self.