• Row1
  • Row1
  • Row1

    JQuery: slowly add div and html with effect

    I am retrieving data using ajax.

      <ul class="products">
    
      <li>Row1</li>
    
      <li>Row1</li>
    
      <li>Row1</li>
    
      <li>Row1</li>
    
      </ul>
    

    when the user clicks on li to be added.

       jQuery(function(){
    
      jQuery('li').click(function(){
    
      jQuery('.products').append('<li class="new-rows"></li>');
    
      jQuery('.new-rows').html(dd , 500);
    
      });
    
     });
    

    now what i'm looking for is whether the new generated display is slow.

    here dd is the content received from another page using ajax;

    check this script: http://jsfiddle.net/adHvb/2/

    +4
    source share
    4 answers

    Try the following: - http://jsfiddle.net/adiioo7/adHvb/6/

    JS: -

    jQuery('li').click(function () {
          dd = 'baba';
          var liData = '<li class="new-rows" style="display:none;"></li>';
          $(liData).appendTo('.products').fadeIn('slow');
    
          jQuery('.new-rows').html(dd, 500);
      });
    
    +6
    source

    , , , , , . ( ) <li>?

    <li> click(), . , ?

    , jQuery.ajax() success.

    jQuery('li').click(function(){
        var $newRow = jQuery('<li class="new-rows"></li>');
    
        jQuery.ajax({
            type: 'type',
            url: 'url',
            data: data,
            success: function(dd){
                $newRow.html(dd).appendTo('.products').hide().fadeIn(1000);     
            }
        });
    
    });
    
    +5

    use jquery animation for good effect

     jQuery('li').click(function(){
      jQuery('.products').append('<li class="new-rows"></li>');
        $( ".new-rows" ).animate({
             opacity: 0.25 //use more parameter for effect
        }, 5000, function() {
             jQuery('.new-rows').html(dd);
           // Animation complete.
       });
    

    });

    +3
    source
    jQuery('li').click(function(){
    dd = 'baba';
    $('<li style="display:none;" class="new-rows"></li>').appendTo('.products').fadeIn('slow');
    jQuery('.new-rows').html(dd , 500);});
    
    +1
    source

    All Articles