Using fadein and append

前端 未结 9 1925
不知归路
不知归路 2020-12-07 10:39

I am loading JSON data to my page and using appendTo() but I am trying to fade in my results, any ideas?

$(\"#posts\").fadeIn();
$(content).appe         


        
相关标签:
9条回答
  • 2020-12-07 11:32
    $(output_string.html).fadeIn().appendTo("#list");
    
    0 讨论(0)
  • 2020-12-07 11:33

    First is convert received data to jQuery Object. Second, hide it immediately. Third, append it to a target node. And, after this all, we can clearly use necessary animation, just like fadeIn :)

    jNode = $("<div>first</div><div>second</div>");
    jNode.hide();
    $('#content').append(jNode);
    jNode.fadeIn();
    
    0 讨论(0)
  • 2020-12-07 11:37

    assuming you have the following in the css defined:

    .new {display:none} 
    

    and the javascript should be :

    $('#content').append('<p class='new'>Hello!</p>');
    $('#content').children('.new').fadeIn();
    $('#content').children.removeClass('new');
    $('#content').children('.new').hide();
    
    0 讨论(0)
提交回复
热议问题