Jquery 将默认活动状态添加到悬停滑动手风琴li
我使用的是水平滑动手风琴,悬停时每个元素都处于活动状态(展开),但在休眠状态下,初始的活动元素应该展开,而不是所有的LIs折叠 请参见示例 HTML JQueryJquery 将默认活动状态添加到悬停滑动手风琴li,jquery,html,css,Jquery,Html,Css,我使用的是水平滑动手风琴,悬停时每个元素都处于活动状态(展开),但在休眠状态下,初始的活动元素应该展开,而不是所有的LIs折叠 请参见示例 HTML JQuery 您只需要添加一些规则来适应这种行为 我在hover上添加了以下内容: $('li').stop().animate({'width':'115px'},1000); 我在悬停结束时添加了以下内容: $('.bg4').stop().animate({'width':'480px'},500); 我强烈建议使用类来分配宽度,而不是
您只需要添加一些规则来适应这种行为 我在hover上添加了以下内容:
$('li').stop().animate({'width':'115px'},1000);
我在悬停结束时添加了以下内容:
$('.bg4').stop().animate({'width':'480px'},500);
我强烈建议使用类来分配宽度,而不是在Javascript中对其进行硬编码。然后,您可以设置类的删除/添加动画。谢谢您!我同意,上课要方便得多。这是我下载的插件,旨在修改它。一旦我查看了js,我意识到宽度是用js硬编码的。另外,是否可以固定宽度参数?而不是手风琴的扩张和收缩。请参见示例:
$(function() {
$('#accordion > li').hover(
function () {
var $this = $(this);
$this.stop().animate({'width':'480px'},500);
$('.heading',$this).stop(true,true).fadeOut();
$('.bgDescription',$this).stop(true,true).slideDown(500);
$('.description',$this).stop(true,true).fadeIn();
},
function () {
var $this = $(this);
$this.stop().animate({'width':'115px'},1000);
$('.heading',$this).stop(true,true).fadeIn();
$('.description',$this).stop(true,true).fadeOut(500);
$('.bgDescription',$this).stop(true,true).slideUp(700);
}
);
$(function() {
$('#accordion').on('click', 'li', function() {
$('.accordion li.active').removeClass('active'); //Remove any "active" class
$('li', this).addClass('active'); //Add "active" class to selected tab
//Commented since it is not available
//$(activeTab).show(); //Fade in the active content
return false;
});
});
});
$('li').stop().animate({'width':'115px'},1000);
$('.bg4').stop().animate({'width':'480px'},500);