最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Callback for jQuery.prepend() function - Stack Overflow

programmeradmin1浏览0评论

is possible to add callback into prepend method? I need to wait until DOM is rebuild and then start fade animation.

$("body").prepend(div);
$(div).css({
  'opacity': 1
});

The animation is made with CSS3 transitions, so I only need to wait for DOM ready and then change the CSS opacity..

Here is fiddle with my problem...

is possible to add callback into prepend method? I need to wait until DOM is rebuild and then start fade animation.

$("body").prepend(div);
$(div).css({
  'opacity': 1
});

The animation is made with CSS3 transitions, so I only need to wait for DOM ready and then change the CSS opacity..

Here is fiddle with my problem...

Share Improve this question edited Sep 6, 2011 at 13:52 simekadam asked Sep 6, 2011 at 12:56 simekadamsimekadam 7,38411 gold badges59 silver badges80 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 1

Here's an update: http://jsfiddle/8MFJQ/4/

prepend doesn't have a callback because the DOM is ready with the call. I'm using Jquery's fadeIn and fadeOut as well to achieve wider browser coverage.

If I'm not wrong you can do it like that $("body").append(div).css({'opacity': 1});. Or maybe you've to change the method for, like this $(div).appendTo('body').css({'opacity': 1});

发布评论

评论列表(0)

  1. 暂无评论