index.html 779 B

1234567891011121314151617181920212223
  1. <!DOCTYPE html>
  2. <!--
  3. TAG NOTES:
  4. <img> tag is a tag in html for images and other media.
  5. -->
  6. <html>
  7. <body>
  8. <h2>Changing HTML attribute values with JavaScript.</h2>
  9. <p>In this example we will change the src (location of the image value) with javascript.</p>
  10. <!-- for some reason in there example they don't use type="button" anymore
  11. we learn here that getElementByID function can be given .src for the src html attribute in the image tag -->
  12. <button onclick='document.getElementById("my_image").src="pic_bulbon.gif"'>Turn on the LIGHT!</button>
  13. <!-- The style image html attribute uses css -->
  14. <img id="my_image" src="pic_bulboff.gif" style="width:100px">
  15. <button onclick='document.getElementById("my_image").src="pic_bulboff.gif"'>Turn OFF the light.</button>
  16. </body>
  17. </html>