简体   繁体   English

淡入jquery中的前置元素

[英]Fading In A prepended element in jquery

I've got some code like this: 我有一些像这样的代码:

var newrootcomment = $("<div class='comment'><div class='comment-holder'><div class='comment-body'>"+ data.message + "</div> <abbr class='timestamp' title=''></abbr><div class='aut'>" + data.author + "</div> <a href='#comment_form' class='reply' id=''>Reply</a> </div> </div>");

$('#wholecontainer').prepend(newrootcomment).hide().fadeIn(300);

Basically, I'm prepending the code to the #wholecontainer div. 基本上,我将代码添加到#wholecontainer div。 however, I want the prepended code and fade it into view. 但是,我想要前置代码并将其淡入视图。 The above code fades in all the #wholecontainer div. 上面的代码在所有#wholecontainer div中消失。 How can I actually do it? 我怎么能真正做到这一点?

尝试

newrootcomment.prependTo($('#wholecontainer')).hide().fadeIn(300);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM