Change button color on click using JS YouTube
So we need to add an onclick attribute to our button, then write the JavaScript function to change the color. So we need to make a slight change in our HTML:
freeCodeCamp
Tutorial sobre button onclick em HTML e evento de clique em JavaScript
Try it Yourself » Another example on how to change the color of an element:
Click me to change my color.
39 Javascript Change Image On Button Click Javascript Answer
Click the button to change the color.