Categories
How to JavaScript

How to pass this element to JavaScript onClick function and add a class to that clicked element?

Estimated read time 1 min read

Use the “onclick” attribute to pass the element to a JavaScript function, then use the “classList.add()” method to add a class to the clicked element.