Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Coloring Divs</title>
- <script>
- function changeColor(color) {
- document.getElementById("fourth-div").style.backgroundColor = color;
- }
- </script>
- <style>
- .container {
- display: flex;
- flex-wrap: wrap;
- }
- .color-option {
- width: 100px;
- height: 100px;
- margin: 10px;
- border: 1px solid black;
- cursor: pointer;
- }
- #fourth-div {
- width: 300px;
- height: 300px;
- margin-top: 20px;
- border: 1px solid black;
- background-color: white;
- }
- </style>
- </head>
- <body>
- <div class="container">
- <div class="color-option" style="background-color: red" onclick="changeColor('red')"></div>
- <div class="color-option" style="background-color: green" onclick="changeColor('green')"></div>
- <div class="color-option" style="background-color: blue" onclick="changeColor('blue')"></div>
- <div id="fourth-div"></div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement