可能的动画jQuery前端? [英] Possible to animate jQuery prepend?
本文介绍了可能的动画jQuery前端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在一个按钮点击前面一些数据到我的页面,而不是只是填充在页面上,我想知道是否有一个方法来动画 prepend()
使用 slideToggle
或CSS动画。
I am prepending some data to my page on a button click and instead of just populating immediately on the page, I was wondering if there is a way to animate the prepend()
using slideToggle
or CSS animation.
这是我当前的脚本:
var data = $('.data').html();
var insert = '<div class="data-container">'+ data +'</div>';
$('button').click(function(){
$('.data-container').remove();
$('.initial').prepend(insert);
});
和 JSFiddle
推荐答案
您必须这样做:
var data = $('.data').html();
var insert = '<div class="data-container">'+ data +'</div>';
$('button').click(function(){
$('.data-container').remove();
$('.initial').hide();
$('.initial').prepend(insert);
$('.initial').slideToggle();
});
这篇关于可能的动画jQuery前端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文