У меня есть аккордеон jQuery с этого сайта, и он отредактирован для моих целей, но аккордеон работает только в Firefox (не Safari или Chrome), и cookie-файлы установлены неправильно
Это jQuery:
function initMenus() {
$('#sidebar .letter_index').hide();
$.each($('#sidebar .letter_index'), function() {
var cookie = $.cookie(this.id);
if (cookie === null || String(cookie).length < 1) {
$('#sidebar .letter_index:first').show();
} else {
$('#' + this.id + ' .' + cookie).next().show();
}
});
$('#sidebar .letter_head').click(function() {
var checkElement = $(this).next();
var parent = this.parentNode.parentNode.id;
if ((checkElement.is('.letter_index')) && (!checkElement.is(':visible'))) {
$('#' + parent + ' .letter_index:visible').slideUp('normal');
if ((String(parent).length > 0) && (String(this.className).length > 0)) {
// not working
$.cookie(parent, this.className);
}
checkElement.slideDown('normal');
return false;
}
}
);
}
$(document).ready(function() {initMenus();});
Вот так выглядит мой HTML (пример элемента):
<div id="sidebar">
<h2 class="letter_head"><a href="#" class="ABC">ABC</h2>
<ul class="letter_index">
<li>Abc</li>
<li>Bcd</li>
</ul>
</div>
Не могу найти проблему, почему скрипт не будет работать в Safari и Chrome.
Я также не знаю, как сказать ему использовать класс a
внутри h2
в качестве значения cookie. (В настоящее время cookie установлен как $.cookie(parent, this.className);
, что создает файлы cookie с именем container
(div выше #sidebar) и значением letter_head
. Это должно быть что-то вроде 'sidebar' и 'ABC', 'DEF и так далее.
Заранее спасибо!