我正在试图弄清楚如何在Foundation的手风琴中将活动类添加到<dd>
。现在,活动状态仅对div中的内容启用,而不是<dd>
上的内容。这就是我所追求的。
问题也在这里描述:http://foundation.zurb.com/forum/posts/1061-accordion-foundation-5
电流:
<dd>
<a href="#panel1">Title</a>
<div id="panel1" class="content active">Content</div>
</dd>
渴望:
<dd class="active">
<a href="#panel1">Title</a>
<div id="panel1" class="content active">Content</div>
</dd>
这是当前foundation.accordion.js的代码:
;(function ($, window, document, undefined) {
'use strict';
Foundation.libs.accordion = {
name : 'accordion',
version : '5.0.1',
settings : {
active_class: 'active',
toggleable: true
},
init : function (scope, method, options) {
this.bindings(method, options);
},
events : function () {
$(this.scope).off('.accordion').on('click.fndtn.accordion', '[data-accordion] > dd > a', function (e) {
var accordion = $(this).parent(),
target = $('#' + this.href.split('#')[1]),
siblings = $('> dd > .content', target.closest('[data-accordion]')),
settings = accordion.parent().data('accordion-init'),
active = $('> dd > .content.' + settings.active_class, accordion.parent());
e.preventDefault();
if (active[0] == target[0] && settings.toggleable) {
return target.toggleClass(settings.active_class);
}
siblings.removeClass(settings.active_class);
target.addClass(settings.active_class);
});
},
答案 0 :(得分:0)
你可以使用jquery来实现这个
on_some_event {
$("dd").addClass("active"); //adds 'active' class to all <dd> elements
$("dd").removeClass("active"); //removes 'active' class from all <dd> elements
$("dd").toggleClass("active"); //toggles 'active' class for all <dd> elements
}