简体   繁体   中英

jQuery - How can i slideDown a body append data?

If i click on #ams2t, everyting is working fine.. But how i can i slidedown images.html?

 $(document).on("click","#ams2t", function(){
       $.get( "images.html", function( data ) {
         $( "body" ).append( data );
      });
    });

I have tried this but that is not working:

 $(document).on("click","#ams2t", function(){
           $.get( "images.html", function( data ) {
             $( "body" ).append( data ).slideDown( "slow");
          });
        });

You can modify the html received from server before it is inserted. The new html has to first be hidden in order to make slideDown possible

$.get( "images.html", function( data ) {
        var $newHtml = $(data).hide();
        $( "body" ).append( $newHtml );
        $newHtml.slideDown()
});

If there isn't a root element to hide ... use wrap() to give it an outer container to hide

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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