开发者

Animate the loading of html content into a div

I have a click fun开发者_开发技巧ction which grabs the contents of one div and loads it into another. I'd like to add a simple fade to that loading. Here's what I have so far:

$("ul.portfolio li a").click(function(e) {
e.preventDefault();
var content = $(this).next('.clickContent').html();
$("#container").html(content).fadeIn('slow');
});

It's not working. The content just loads. Any idea how to get this to animate??

Thanks in advance!


You need to hide the div first:

$("ul.portfolio li a").click(function(e) {
    e.preventDefault();
    var content = $(this).next('.clickContent').html();
    $("#container").hide().html(content).fadeIn('slow'); // added .hide()
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜