2 Replies - 765 Views - Last Post: 29 March 2010 - 09:27 PM

#1 letschopcats   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 27-August 09

jQuery question

Posted 29 March 2010 - 08:14 PM

I just started learning jQuery and I love it. I'm just having trouble figuring out how to make something happen over and over like a loop. The documentation on the jQuery website is a little confusing when it comes to this. If I could just get pointed in the right direction I'd be more than grateful.

I have this image that I got to animate itself down the page at random points in the browsers width. Now I want it to do it automatically without me refreshing the page. This is what I have so far. Any resources or hints would be awesome! Thank you so much in advance.

#ash = my image ID
#container = div around img

	
$(function () {
var random = Math.floor(Math.random(8) * $(window).width());
var $ash = jQuery('#ash');
var $con = jQuery('#container');
		
$con.css( {"width" : $(document).width(),
	   "height" : $(window).height()
})
$ash.css( "left" , random);
$ash.animate({ 
	"top" : $(window).height() - 269,
	"opacity" : 0
	}, 2000);
});	


Is This A Good Question/Topic? 0
  • +

Replies To: jQuery question

#2 letschopcats   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 27-August 09

Re: jQuery question

Posted 29 March 2010 - 09:12 PM

I figured it out. I used a callback. I'll post the fixed code if anyone's interested.
Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder   User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1663
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: jQuery question

Posted 29 March 2010 - 09:27 PM

Moved to jQuery Forum :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1