Link to home
Start Free TrialLog in
Avatar of jagguy
jagguyFlag for Australia

asked on

jqery function wont work

Hi, Why cant the following jquery work when I place the code in a separate function as below

I get no error but no animation.

$(document).ready(function(){
 
  var $val1=6;
  var $val2=10.3;
  var img = ["images/bcave1.png", "images/bcave2.png"];
  var indexNum=0;
  
	setInterval("animatepic1()",100);
 /*  var gameLoop = setInterval( function(){
	  $("#pic").attr("src", img[indexNum]);
      indexNum++;	
      if (indexNum >= 2) {indexNum = 0;} 
	   
	   } , 100);
	   */
  
 
   
 }); 
 
   function animatepic1(){
			 $("#pic").attr("src", img[indexNum]);
     		 indexNum++;	
      		 if (indexNum >= 2) {indexNum = 0;} 
	   
	    }

.....
<img id ="pic" src="images/bcave1.png" alt="eight ball" />

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ersoy Hasan
Ersoy Hasan
Flag of Bulgaria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial