I’m basically trying to alter the background-position on a div twice in fairly quick succesion . Heres my current code:
$('.slide1').css({'margin':' 0 0 0 1000px','display':'none'}).delay(2400).show().animate({marginLeft: 0},1000, function(){
$('.accordion').css('background','#000');
$('.shadow-horizontal').css('visibility','visible');
$('.panel:nth-child(2)').delay(2000).css('background-position','0px top'); //this one doesn't seem to fire
$('.panel:nth-child(2)').delay(2000).css('background-position','-410px top'); //this one does
});
Whats happening is only the second change is taking place. The first one doesn’t seem to be affected at all.
I’ll note that I need to do it using jQuery and ideally I’d prefer to wrap the jquery .css changes in a function and just call that were the current jQuery .css changes are.
I also tried a long string version too that didn’t work.
$('.panel:nth-child(1)').css('background-position','0px top').delay(500).css('background-position','-41px top');
Here’s a live version of where I’m at: http://faithandsony.co.uk/sony_accordion_hover-hightlight/
Thanks in advance for any answers. I’m around to answer any questions.
This could just be a timing issue. You could use a simple
timeout()to perform the first before the second, making the second CSS change wait 1000ms (or 1 second) before executing.Alternatively, keep the delay for the first at 2000, and change the second to 4000, giving: