i am fetching data using ajax.
<ul class="products">
<li>Row1</li>
<li>Row1</li>
<li>Row1</li>
<li>Row1</li>
</ul>
when user click on li the li will append.
jQuery(function(){
jQuery('li').click(function(){
jQuery('.products').append('<li class="new-rows"></li>');
jQuery('.new-rows').html(dd , 500);
});
});
now what i am looking for is new generated li display slowly.
here dd is the content getting from another page using ajax;
check this fiddle : http://jsfiddle.net/adHvb/2/
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);
});
All the answers here regarding animation and effects are really good but I am mostly concern about the fetching part since you didn't include that. Do you fetch the data on the start(document ready) or only when <li>
is clicked?
If you fetch the data when the <li>
click()
event is fired you cannot just set a specific delay for the animation. What if it took some time to fetch the data?
I think you should do the appending and animation on jQuery.ajax()
success
function.
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);
}
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With