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
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
, , , , , . ( ) <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