Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <head> <script> function lighton() { document.getElementById('myimage').src = "bulbon.gif"; } function lightoff() { document.getElementById('myimage').src = "bulboff.gif"; } </script> </head> <body> <h1>JavaScript HTML Events</h1> <h2>The onmousedown Attribute</h2> <img id="myimage" onmousedown="lighton()" onmouseup="lightoff()" src="bulboff.gif" width="100" height="180" /> <p>Click mouse and hold down!</p> </body> </html>