Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=<device-width>, initial-scale=1.0">
- <title>Probando JavaScript</title>
- </head>
- <body>
- <button onclick="modificar('Blue')">Blue</button>
- <button onclick="modificar('Red')">Red</button>
- <button onclick="modificar('Green')">Green</button>
- <button onclick="modificar('Pink')">Pink</button>
- <p id="color"></p>
- <script>
- function modificar(nombre) {
- document.getElementById("color").innerHTML = "El color es " + nombre;
- document.getElementById('color').style.backgroundColor = nombre;
- }
- </script>
- </body></html>
Advertisement
Add Comment
Please, Sign In to add comment