JS - Modificar atributos

by Manuel Gertrudix

HTML

<!DOCTYPE html>
<html>
  <body>

    <h1>Cambiar atributos con JS</h1>

    <p>En este caso vamos a cambiar imágenes. Atributo src de la etiqueta img</p>


    <button onclick="document.getElementById('myImage').src='https://files.ciberimaginario.es/07-master/js/sol-encendi.jpg'">Enciende el sol</button>

    <img id="myImage" src="https://files.ciberimaginario.es/07-master/js/sol-apagado.jpg" style="width:90px">

    <button onclick="document.getElementById('myImage').src='http://cdn5.dibujos.net/dibujos/pintar/sol-6-colorear.jpg'">Apaga el sol</button>

  </body>
</html>