开发者

Callback for jQuery.prepend() function

开发者 https://www.devze.com 2023-04-03 03:30 出处:网络
is possible to add callback into prepend method? I need to wait until DOM is rebuild and the开发者_如何学JAVAn start fade animation.

is possible to add callback into prepend method? I need to wait until DOM is rebuild and the开发者_如何学JAVAn 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...


Here's an update: http://jsfiddle.net/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

精彩评论

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