středa 2. prosince 2015

Change picture on click

A following simple example shows how to write the html page with pictures that rotate on mouse click event.

<html>
<head>

<script>
function changeImageOnClick(){
    image=document.getElementById("image1");
    
        if(image.src.indexOf("pict1.png")<0)
            image.src="pict1.jpg";
        else
            image.src="pict2.jpg";
}
</script>
</head>
<body>

<img src="pict1.png" id="image1" onclick="changeImageOnClick()"/>

</body>
Here is the working example:

Žádné komentáře:

Okomentovat