Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
для создания одного jQuery запроса, вместо последовательной выборки
document.documentElement.id = 'js';
#js DD { display:none; }jQuery.fn.accordion = function() {
function update(dl) {
$("dt:not(.active)", dl).css("cursor", "pointer");
$("dt.active", dl).css("cursor", "");
$("dd div", dl).hide();
$("dd span.remark", dl).show();
$("dt.active", dl).next().children("div").show(300);
$("dt.active", dl).next().children("span.remark").hide();
}
return this.each(function() {
var dl = $(this), active = $("dt.active", dl);
update(dl);
$("dt", dl).click(function() {
if (!$(this).hasClass("active")) {
active && active.removeClass("active");
active = $(this).addClass("active");
update(dl);
}
});
});
};
Пишем аккордеон-плагин в 618 байт