Advertisement
irmantas_radavicius

Untitled

Feb 6th, 2022
1,122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.79 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <title>Title</title>
  5.     <meta charset="UTF-8">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <style>
  8.         #container1 {
  9.             width: 200px;
  10.             height: 200px;
  11.             background-color: green;
  12.         }
  13.         #container2 {
  14.             width: 200px;
  15.             height: 200px;
  16.             background-color: red;
  17.         }
  18.     </style>
  19.  
  20.    
  21. </head>
  22. <body id="body">
  23.     <div id="container1" onclick="change('gray', 'purple');">
  24.     </div>
  25.     <div id="container2" onclick="change('yellow', 'blue');">
  26.     </div> 
  27.     <script>
  28.         function change(color1, color2){
  29.             let cont1 = document.getElementById("container1");
  30.             cont1.style.backgroundColor = color1;
  31.             let cont2 = document.getElementById("container2");
  32.             cont2.style.backgroundColor = color2;
  33.         }          
  34.     </script>
  35. </body>
  36. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement