Home >Web Front-end >JS Tutorial >Registering events multiple times will cause an event to be triggered multiple times_javascript tips
A JavaScript logic will automatically bind the function to the click event of the button, but this code will register the event repeatedly. This relies on the onNext function to be triggered multiple times when the button is clicked.
This is because JQuery does not internally determine whether to bind multiple times. It is suspected that it uses an array internally to save the event function, and does not remove duplicates.
The following code prevents this problem. The solution is simple.