screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head></head> <body> <h3>Change Button Color on click Javascript</h3> <button id="myButton" class="button">Click Me</button> <script> var button = document.getElementById("myButton"); button.addEventListener("click", function () { this.style.backgroundColor = "red"; }); </script> <style> .button { width: 100%; background-color: blue; color: white; padding: 10px 20px; border: none; border-radius: 4px; font-size: 16px; cursor: pointer; transition: background-color 0.3s ease; } </style> </body> </html>