jquery prepend+;法丹
我有以下代码:jquery prepend+;法丹,jquery,ajax,jquery-animate,Jquery,Ajax,Jquery Animate,我有以下代码: $.ajax({ url : url, data : {ids : JSON.stringify(jsonids), hotel_id: hotel_id}, success : function(response) { $('#be-images ul').prepend(response).fadeIn('slow'); }, dataType: 'html
$.ajax({
url : url,
data : {ids : JSON.stringify(jsonids), hotel_id: hotel_id},
success : function(response)
{
$('#be-images ul').prepend(response).fadeIn('slow');
},
dataType: 'html'
});
但是淡入不起作用…我希望内容预先准备好并淡入…我将如何做到这一点
提前谢谢 假设
response
是HTML,然后尝试以下操作:
$(response).hide().prependTo("#be-images ul").fadeIn("slow");
当您这样做时:
$('#be-images ul').prepend(response).fadeIn('slow');
实际上,您正在淡入的是初始选择器(前面的列表)的结果,它已经是可见的。+1给cletus,但我只想突出显示另一种方法
$('#be-images ul').prepend(
$(response).hide().fadeIn('slow')
);
试试这个:
HTML
添加
Jquery:
$('button').click(function() {
$('#data').prepend('<div class="item">Test</div>'"');
$("#data .item:first-child").hide();
$("#data .item:first-child").fadeIn();
});
$(“按钮”)。单击(函数(){
$(“#data”).prepend('Test');
$(“#data.item:第一个子项”).hide();
$(“#data.item:first child”).fadeIn();
});
现场演示:克莱特斯和尼克,你们的方法都很棒。我偶然发现了同样的问题,你们的两种方法都可以轻松地工作…谢谢…@cletus:我也有同样的问题,但我的数据是json数组。我使用了。每个函数都试图预加,但它没有显示任何数据预加-
var li='+item.img+$('.twitter list').prepend(li).hide().fadeIn(“fast”);
这很有效,因为它不隐藏要预加的元素,只隐藏要预加的元素
$('button').click(function() {
$('#data').prepend('<div class="item">Test</div>'"');
$("#data .item:first-child").hide();
$("#data .item:first-child").fadeIn();
});