jquery prepend + fadeIn

前端 未结 3 1393
猫巷女王i
猫巷女王i 2020-12-23 13:36

I have this code:

$.ajax({
        url : url,
        data : {ids : JSON.stringify(jsonids), hotel_id: hotel_id},
        success : function(response)
               


        
相关标签:
3条回答
  • 2020-12-23 14:05

    +1 to cletus, but I just wanted to highlight the other way you could do it.

    $('#be-images ul').prepend(
        $(response).hide().fadeIn('slow')
    );
    
    0 讨论(0)
  • 2020-12-23 14:10

    Try this: HTML

    <button>Add</button>
    <div id="data"></div>
    

    Jquery:

    $('button').click(function() {
      $('#data').prepend('<div class="item">Test</div>'"');
        $("#data .item:first-child").hide();
       $("#data .item:first-child").fadeIn();
    });
    

    Live Demo: jsfiddle

    0 讨论(0)
  • 2020-12-23 14:15

    Assuming response is HTML then try this:

    $(response).hide().prependTo("#be-images ul").fadeIn("slow");
    

    When you do it this way:

    $('#be-images ul').prepend(response).fadeIn('slow');
    

    the thing you're actually fading in is the result of the initial selector (the list at the front), which is already visible.

    0 讨论(0)
提交回复
热议问题