I won't 开发者_运维知识库post my whole script because it's most likely irrelevant and will save wasting time.
Why does the following code work:
if (rand === 0)
{
$('#idOfElementInsideContainer')
.animate({padding: ap, background : ab}, {duration:ad})
}
and this not:
if (rand === 0)
{
$('#container:nth-child(1)')
.animate({padding: ap, background : ab}, {duration:ad})
}
I've put an alert after the animate line just to prove to myself that it is actually going inside if statement.
Try this instead:
$('#container').children().eq(1)
.animate({padding: ap, background : ab}, {duration:ad})
精彩评论