开发者

Simple jQuery nth-child query - animations not working

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})
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜