Shadowing Posted April 18, 2012 Share Posted April 18, 2012 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 More sharing options...
dsonesuk Posted April 18, 2012 Share Posted April 18, 2012 It only works with elements using animation queue, yours has non, so you have to add the queue $("div.l1").css("color","gold").delay(4000).queue(function() {$(this).css("color","#E0E0E0");}); Link to comment Share on other sites More sharing options...
Shadowing Posted April 18, 2012 Author Share Posted April 18, 2012 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 list Link to comment Share on other sites More sharing options...
Shadowing Posted April 18, 2012 Author Share Posted April 18, 2012 apparently using dequeue is some what working. but for some reason the timing is all off Link to comment Share on other sites More sharing options...
dsonesuk Posted April 18, 2012 Share Posted April 18, 2012 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.