开发者

JQuery animate always removes display:none and adds display:block to inline css

I'm running some simple jquery for animation over a group of images. Some of the images are hidden and some are not. But it seems jquery is just making them all visible, I want to animate these with changing how they display.

$('.productImageLarge').animate({
    width: 185,
    height: 185
});  

JQuery automatically makes them all display:block.

Is it possible to animate withou开发者_JAVA百科t changing the display visibility.

Thanks


If you set the specify the display property and add a !important declaration jQuery will restore the display property after it completes its animation. For example, if you run this command on the jQuery homepage it will set the first book image to display:inline, animate it and then validate that the resulting HTML has the correct display property.

$($(".jq-bookImg").get(0))
    .css("display","inline !important")
    .animate({ width: 85, height: 185 }, function(){
        console.log("display propery is " + $(this).css("display"));
    }
);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜