开发者

Animate the loading of html content into a div

开发者 https://www.devze.com 2023-02-13 14:12 出处:网络
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:

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

精彩评论

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