Jquery 手风琴菜单动画问题
我已经基于一个找到的jquery ui创建了简单的手风琴菜单。我在设置元素动画时遇到了问题,当单击时,我无法正确使用向上或向下滑动动画,如果使用它,会出现许多其他问题。因此,在获得动画方面,任何帮助都将是巨大的 JS小提琴: 剧本Jquery 手风琴菜单动画问题,jquery,Jquery,我已经基于一个找到的jquery ui创建了简单的手风琴菜单。我在设置元素动画时遇到了问题,当单击时,我无法正确使用向上或向下滑动动画,如果使用它,会出现许多其他问题。因此,在获得动画方面,任何帮助都将是巨大的 JS小提琴: 剧本 $(document).ready(function() { var notfContainer = $('#notifications'); notfContainer.fi
$(document).ready(function() {
var notfContainer = $('#notifications');
notfContainer.find("a").each(function() {
var e = $(this);
if(!e.hasClass('active')) {
e.next().css({
'display':'none'
}); //hide all other div's and set height as 0px
}
});
notfContainer.on('click' , function(event) {
var target = $(event.target); //Used to find the element on which the click event has happened.
if(target.is("a")) { //If the click event occurred on <a>
var self = $(target); //Select the element
if(self.hasClass('active')) { //If is is already expanded .. has active class
return; //just .. return
}else {
notfContainer.find("a").each(function() {
var e = $(this);
if(e.hasClass('active')) {
e.removeClass('active');
e.next().css('display','none'); //hide all other div's
return false; //break the loop
}
});
self.addClass('active');
self.next().css({
'display':'block',
'height':'160px'
});
}
}
});
});
$(文档).ready(函数(){
var notfContainer=$(“#通知”);
notfContainer.find(“a”).each(函数(){
var e=$(本);
如果(!e.hasClass('active')){
e、 next().css({
“显示”:“无”
});//隐藏所有其他div并将高度设置为0px
}
});
notfContainer.on('click',函数(事件){
var target=$(event.target);//用于查找发生单击事件的元素。
if(target.is(“a”){//如果单击事件发生在
var self=$(target);//选择元素
if(self.hasClass('active'){//if已展开..具有活动类
return;//只是..return
}否则{
notfContainer.find(“a”).each(函数(){
var e=$(本);
if(e.hasClass('active')){
e、 removeClass(“活动”);
e、 next().css('display','none');//隐藏所有其他div
return false;//中断循环
}
});
self.addClass('active');
self.next().css({
“显示”:“块”,
“高度”:“160px”
});
}
}
});
});
jQuery:
$(document).ready(function() {
$('#notifications a.active').next('div').siblings('div').hide();
$('#notifications a').click(function() {
$(this).addClass('active').siblings('a').removeClass('active');
var el = $(this).next('div');
check = (el.is(':visible')) ? el.slideUp() : function(){ $('#notifications div').slideUp(); el.slideDown(); }();
});
});