하위 메뉴가 열리면 페이지가 앵커 링크로 이동하지 않는다는 점을 제외하고는 큰 효과가있는 바닥 글에 jquery 아코디언 메뉴가 있습니다. 이것이 내 꼬리말에 있기 때문에 아래로 스크롤하여 열린 하위 메뉴를보아야합니다. 페이지가 자동으로 아래로 스크롤되기를 원합니다.Jquery 아코디언 메뉴가 앵커 태그로 스크롤되지 않음
이것이 작동하지 않는 이유는 무엇입니까? 나는 또한 ID를 퍼팅 시도했지만 작동하지 않았다.
내 HTML :
<ul class="footer-offices">
<li id="#sanfran" class="one"><a href="#sanfran">text</a>
<ul class="submenu"><li>office info here</li></ul>
</li>
</ul>
JQuery와는 다음과 같습니다
$(document).ready(function(){
$("ul.footer-offices li > a").on("click", function(e){
if($(this).parent().has("ul")) {
e.preventDefault();
}
if(!$(this).hasClass("open")) {
// hide any open menus and remove all other classes
$("ul.footer-offices li ul").slideUp(350);
$("ul.footer-offices li a").removeClass("open");
// open our new menu and add the open class
$(this).next("ul").slideDown(350);
$(this).addClass("open");
}
else if($(this).hasClass("open")) {
$(this).removeClass("open");
$(this).next("ul").slideUp(350);
}
}); });
이것은 SO 질문에 대한 너무 많은 코드입니다. 가장 관련성이 높은 코드를 10 줄 이하로 줄이는 것이 좋습니다. –
CSS를 제거했습니다 ... 문제 해결이 필요한지 확실하지 않습니다 ... jquery에서 무엇을 잘라낼 수 있는지 잘 모르겠습니다. – Beth