Jump to content

understanding delay


Shadowing
 Share

Recommended Posts

Hey guys im confused why i cant make this code trip in order it turns the div gold but then just ignores the 2nd request of turning it to #E0E0E0 anyone have any ideas why?

$(function(){ function display() {   $("div.l1").css("color","gold");		  	$("div.l1").delay(4000).css("color","#E0E0E0"); } });

Link to comment
Share on other sites

thanks for the responce dsonesuk.wierd all the hours sitting here googling this no one ever mention queue. my only other problem now is the last one doesnt work.just doesnt make sense to me how the 2nd one can trip but not the last one.

$("div.l1").css("color","gold").delay(2000).queue(function() {	  $(this).css("color","#E0E0E0");	});		$("div.l2").delay(3000).queue(function() {	  $(this).css("color","gold");		});		$("div.l2").delay(6000).queue(function() {	  $("div.l2").css("color","#E0E0E0");	});

see im trying to make each list row turn color then back to its orginal color. so cycle through the listflip.jpg

Link to comment
Share on other sites

I would consider using setTimeout() JavaScript function, it can be done with jquery (below) but it would be smaller code with settimeout.

$(function(){var timedelay=2000;$(".l1 p").eq(0).css("color","gold");$(".l1 p").eq(1).css("color","#E0E0E0").delay(timedelay*1).queue(function() {$(".l1 p").css("color","#E0E0E0");$(".l1 p").eq(1).css("color","gold");});$(".l1 p").eq(2).css("color","#E0E0E0").delay(timedelay*2).queue(function() {$(".l1 p").css("color","#E0E0E0");$(".l1 p").eq(2).css("color","gold");});$(".l1 p").eq(3).css("color","#E0E0E0").delay(timedelay*3).queue(function() {$(".l1 p").css("color","#E0E0E0");$(".l1 p").eq(3).css("color","gold");});});

<div class="l1">  <p>Ut labore et dolore magna aliqua. Ut enim ad minim veniam, eu fugiat nulla    pariatur. Lorem ipsum dolor sit amet, excepteur sint occaecat cupidatat non    proident. Ut aliquip ex ea commodo consequat.</p>  <p>Velit esse cillum dolore qui officia deserunt sed do eiusmod tempor incididunt.    Lorem ipsum dolor sit amet, sunt in culpa in reprehenderit in voluptate.    Quis nostrud exercitation velit esse cillum dolore mollit anim id est laborum.</p>      <p>Velit esse cillum dolore qui officia deserunt sed do eiusmod tempor incididunt.    Lorem ipsum dolor sit amet, sunt in culpa in reprehenderit in voluptate.    Quis nostrud exercitation velit esse cillum dolore mollit anim id est laborum.</p>      <p>Velit esse cillum dolore qui officia deserunt sed do eiusmod tempor incididunt.    Lorem ipsum dolor sit amet, sunt in culpa in reprehenderit in voluptate.    Quis nostrud exercitation velit esse cillum dolore mollit anim id est laborum.</p></div>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...