나는이 http://www.i-marco.nl/weblog/jquery-accordion-menu/ 아코디언 메뉴를 사용하고 있습니다.jquery accordion menu - link problem
문제는 메인 메뉴 링크가 하위 메뉴를 확장하기 위해서만 작동하지만, 은 링크 자체로서의 기능을하지 않는다는 것입니다. 주 메뉴 링크를 링크로 이동하고 (PHP 스크립트를 통해 확장 클래스를 설정합니다) 하위 메뉴를 펼치 길 원합니다.
HTML (예) : 여기
코드의<span class="acc_menu">
<ul class="menu">
<li class="expand">
<a href="/a_page.html">A page</a>
<ul class="menu nestedmenu acitem">
<li><a href="/other_page.html">Other page</a></li>
<li><a href="/other_page2.html">Other page 2</a></li>
<li><a href="/other_page3.html">Other page 3</a></li>
</ul>
</li>
</ul>
JQuery와 :
jQuery.fn.initMenu = function() {
return this.each(function(){
var theMenu = $(this).get(0);
$('.acitem', this).hide();
$('li.expand > .acitem', this).show();
$('li.expand > .acitem', this).prev().addClass('active');
$('li a', this).click(
function(e) {
e.stopImmediatePropagation();
var theElement = $(this).next();
var parent = this.parentNode.parentNode;
if($(parent).hasClass('noaccordion')) {
if(theElement[0] === undefined) {
window.location.href = this.href;
}
$(theElement).slideToggle('normal', function() {
if ($(this).is(':visible')) {
$(this).prev().addClass('active');
}
else {
$(this).prev().removeClass('active');
}
});
return false;
}
else {
if(theElement.hasClass('acitem') && theElement.is(':visible')) {
if($(parent).hasClass('collapsible')) {
$('.acitem:visible', parent).first().slideUp('normal',
function() {
$(this).prev().removeClass('active');
}
);
return false;
}
return false;
}
if(theElement.hasClass('acitem') && !theElement.is(':visible')) {
$('.acitem:visible', parent).first().slideUp('normal', function() {
$(this).prev().removeClass('active');
});
theElement.slideDown('normal', function() {
$(this).prev().addClass('active');
});
return false;
}
}
}
);
});
};
$(document).ready(function() {
$('.menu').initMenu();
}); // enter code here
내가나요 제거 이것을 정확히 이해 하는가? 최상위 링크가 실제 링크처럼 작동하고 하위 수준 메뉴가 표시되기를 원하십니까? – polarblau
예, 올바르게 이해했습니다. o) – okdan
현재 페이지의 요소에서 URL을 열리시겠습니까? 또는 링크가 완전히 새로운 페이지를 여는 경우? –