开发者

Simple jQuery nth-child query - animations not working

开发者 https://www.devze.com 2023-04-12 01:44 出处:网络
I won\'t 开发者_运维知识库post my whole script because it\'s most likely irrelevant and will save wasting time.

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

精彩评论

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