jquery prepend + fadeIn

烂漫一生 提交于 2019-11-29 20:34:44

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.

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

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!