Skip to content
Advertisement

how to activated new function after button clicked for three times

i want to add new function after i clicked the button 3 times and erase/remove the former function

html file:

JavaScript

javascript:

JavaScript

// i want this btn1 have function to clear function toRed and add toBlue instead after clicked 3 times

Advertisement

Answer

remove the event listener and add a new one when it was clicked three times:

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement