Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <title>Title</title>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <style>
- #container1 {
- width: 200px;
- height: 200px;
- background-color: green;
- }
- #container2 {
- width: 200px;
- height: 200px;
- background-color: red;
- }
- </style>
- </head>
- <body id="body">
- <div id="container1" onclick="change('gray', 'purple');">
- </div>
- <div id="container2" onclick="change('yellow', 'blue');">
- </div>
- <script>
- function change(color1, color2){
- let cont1 = document.getElementById("container1");
- cont1.style.backgroundColor = color1;
- let cont2 = document.getElementById("container2");
- cont2.style.backgroundColor = color2;
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement