Javascript can change attributes:
HTML file: | Displayed by browser: |
---|---|
<!DOCTYPE html>
<html> <body> <script> function light(sw) { var pic; if (sw == 0) { pic = "images/pic_bulboff.gif" } else { pic = "images/pic_bulbon.gif" } document.getElementById('myImage').src = pic; } </script> <img id="myImage" src="images/pic_bulboff.gif" width="100" height="180"> <p> <button type="button" onclick="light(1)">Light On</button> <button type="button" onclick="light(0)">Light Off</button> </p> </body> </html> |
![]()
|
Now isn't this a lot of fun? Makes you want to go for that Javascript training, doesn't it?