<html>
<body>
<script>
function changeImage()
{
element=document.getElementById('myimage')
if (element.src.match("bulbon"))
{
element.src="http://www.w3schools.com/htmldom/pic_bulboff.gif";
}
else
{
element.src="http://www.w3schools.com/htmldom/pic_bulbon.gif";
}
}
</script>
<img id="myimage" onclick="changeImage()" border="0" src="pic_bulboff.gif" width="100" height="180">
<p>Click to turn on/off the light</p>
</body>
</html>
hasilnya
Click to turn on/off the light
jssource blog | javascript blog | script blog | sourcejs blog | html source | js html blog | jssource html | source html | code js html | js code | html code
BalasHapus