Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JavaScript Can Change Images</h1>
- <img id="myImage" onclick="changeImage()" src="http://www.w3schools.com/js/pic_bulboff.gif" width="100" height="180">
- <p>Click the light bulb to turn on/off the light.</p>
- <script>
- function changeImage() {
- var image = document.getElementById('myImage');
- if (image.src.match("bulbon")) {
- image.src = "http://www.w3schools.com/js/pic_bulboff.gif";
- } else {
- image.src = "http://www.w3schools.com/html/pic_bulbon.gif";
- }
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement