Animating image using javascript

Animating image using JavaScript
- Using JavaScript function document.getElementById() we can create simple image animation as given below:

E.g.

<html>
<head>
<title>Click Image to Animate
</title>
</head>
<body>
Click Image to Animate
<br>
<img id="imageid" onclick="imgchange()" 
src="img1.png">
<script>
function imgchange() 
{
var image = document.getElementById("imageid");
if (image.src.match("img1")) 
{
image.src = "img2.png";
} 
else if(image.src.match("img2"))
{
image.src="img3.png";
}
else if(image.src.match("img3"))
{
image.src="img4.png";
}
else 
{
image.src = "img1.png";
}
}
</script>
</body>
</html>
Check Output:

Download Codes
Related Topics:

  1. JavaScript Introduction
  2. Variables in JavaScript
  3. JavaScript Function
  4. Accessing JavaScript Function
  5. Creating JavaScript interactive form
  6. Accessing form field value
  7. Creating interactive form login webpage
  8. Networking Fundamentals
  9. TCP/IP and Internet addressing
  10. Internet Working
  11. Internet Working Servers
  12. Concept and need for web publishing
  13. Web languages
  14. Javascript Control Structure
  15. Checking Text is Letter/s
  16. Checking Text is Number/s
  17. Checking Textbox is Empty or not
  18. Addition of two numbers
  19. Subtraction of two numbers
  20. Multiplication of two numbers
  21. Division of two numbers
  22. Form field validations
  23. Email validation