那里's no simple solution from what I know, but you can override some attributes on load so that the active item is displayed by default. You' d必须以手风琴开始,没有任何项目是活动的,即没有一个手风琴项目有 .is-active 类:
//Initialise the Foundation plugins
$(document).foundation();
function activateWithoutAnimation(itemIndex) {
//Get the accordion item according to its index (0 based)
var $accordionItem = $('.accordion-title:eq(' + itemIndex + ')');
//Set the aria attributes of the accordion item you want to appear
$accordionItem.attr('aria-expanded', 'true');
$accordionItem.attr('aria-selected', 'true');
//Set the attributes of the content.
$accordionItem.next().attr('aria-hidden', 'false');
$accordionItem.next().css('display', 'block');
//This is essential as it lets foundation know that the item is active (to re-allow toggling)
$accordionItem.trigger('click');
}
//Call the function.
activateWithoutAnimation(0);
2 回答
那里's no simple solution from what I know, but you can override some attributes on load so that the active item is displayed by default. You' d必须以手风琴开始,没有任何项目是活动的,即没有一个手风琴项目有
.is-active
类:Html:
jQuery:
可能有更好的方法来执行上述操作,但从我读过的内容来看,没有允许禁用动画的选项 . 我试过覆盖基金会提供的默认值无济于事 .
Fiddle Demo
CSS Solution
如果在初始加载时使用默认帮助程序类
.is-active
,那么一些普通的css可以消除幻灯片打开动画 .https://jsfiddle.net/r6jvbohu/