Javascript 将insertAfter更改为。设置动画
我有jquery代码,可以在div中向上或向下滑动元素 单击一个项目时,它会滑下较大的分区。 我喜欢下滑效果,但它会同时打开所有其他div 我的问题是:有没有一种方法可以设置css显示:块的动画 打开此按钮:Javascript 将insertAfter更改为。设置动画,javascript,jquery,html,css,animation,Javascript,Jquery,Html,Css,Animation,我有jquery代码,可以在div中向上或向下滑动元素 单击一个项目时,它会滑下较大的分区。 我喜欢下滑效果,但它会同时打开所有其他div 我的问题是:有没有一种方法可以设置css显示:块的动画 打开此按钮: $('.myClass').insertAfter(this.css('display','block') 进入这个: $('.myClass').animate({display:'block'},{duration:700}) 但是.animate({display:'block'},
$('.myClass').insertAfter(this.css('display','block')代码>
进入这个:
$('.myClass').animate({display:'block'},{duration:700})代码>
但是.animate({display:'block'},{duration:700})代码>它不工作
我也试过:
$('.myClass').insertAfter(this).animate({display: 'block'}, {duration: 700});
但它不会打开隐藏的大div
下面是jquery的一部分
if ($(this).hasClass('currentbox')) {
/**** If next inline item is clicked - gets class currentbox - slide toggle *****/
$('.superbox-show-'+currentbox).slideToggle(700);
} else {
/**** Initial-First click, If click is first time or box is hidden*****/
/**** I like the slideDown effect but it opens all other hidden divs at same time *****/
//$('.superbox-show-'+currentbox).slideDown(700);
/**** I have to use this which does just opens the large div with no effect *****/
$('.superbox-show-'+currentbox).insertAfter(this).css('display', 'block');
/**** Hide all other divs *****/
$('.superbox-show-'+currentbox).nextAll('.superbox-show').css('display', 'none');
$('.superbox-show-'+currentbox).prevAll('.superbox-show').css('display', 'none');
}
但是.动画({display:'block'},{duration:700});它不起作用
试一试
如果你只使用<代码>。()(代码)>在中间没有任何数字或“慢”或“快”,它将立即显示,没有动画。但是如果你使用一个数字,比如700,也就是700毫秒,它将执行一种显示元素的动画。
也发布你的相关HTML。这样我们就可以大致了解你到底在做什么。。。或者JSFIDLE中的一个示例会更好您只能为CSS数值设置动画。你怎么能动画显示CSS属性?!html是动态创建的,我将尝试使用一些虚拟内容创建JSFIDLE。只有在div打开时,才可以向该div添加css转换吗?因为如果它已经打开,它将滑动切换。
$('.myclass').show(700);