click
event listener for two functions: func1
, func2
to document object.
After clicking three times we remove the event listener for func1
functionlet counter = 0;
document.addEventListener('click', func1);
document.addEventListener('click', func2);
function func1(){
console.log('You clicked me!');
if (counter>2) {
console.log('Max limit is 3');
document.removeEventListener('click', func1);
}
}
function func2(){
counter ++;
console.log('counter: '+counter);
}