Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <script>
- document.addEventListener("DOMContentLoaded", () => {
- const buttons = document.querySelectorAll("button");
- for (const button of buttons) {
- button.addEventListener("click", () => {
- document.querySelector("h1").style = `color: ${button.innerText.toLowerCase()}`;
- })
- }
- });
- </script>
- <title>Colors</title>
- </head>
- <body>
- <h1>Change Me!</h1>
- <button>Red</button>
- <button>Blue</button>
- <button>Green</button>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement