I had an HTML form with a character countdown indicator on a textarea, using old school JavaScript. I have converted this to an event listener but I’m not sure I have done the best job. Can anyone see if I have missed anything? Ta
No you haven’t. All you have done is to pull the event handler out of the HTML and put that in the script without converting it to a listener. To convert it to a listener you’d rewrite it as:
Listeners have the advantage over the old style event handlers that your code is still using in that you can attach multiples of the same listener to the same element without the second overwriting the first and you can then remove any of them if required while leaving the others intact.