teslariu

ej adicional

Jul 20th, 2022
1,100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <meta name="viewport" content="width=<device-width>, initial-scale=1.0">
  7.     <title>Probando JavaScript</title>
  8. </head>
  9. <body>
  10.     <button onclick="modificar('Blue')">Blue</button>
  11.     <button onclick="modificar('Red')">Red</button>
  12.     <button onclick="modificar('Green')">Green</button>
  13.     <button onclick="modificar('Pink')">Pink</button>
  14.     <p id="color"></p>
  15.    
  16.     <script>
  17.         function modificar(nombre) {
  18.             document.getElementById("color").innerHTML = "El color es " + nombre;
  19.             document.getElementById('color').style.backgroundColor = nombre;
  20.     }
  21.    
  22.    
  23.     </script>
  24.    
  25. </body></html>
  26.  
Advertisement
Add Comment
Please, Sign In to add comment