0
我有以下jQuery,它的工作正常。我需要的是當手風琴被點擊時將用戶帶到活躍手風琴的頁首。如何點擊手風琴時滾動到頁面頂部?
下面是代碼:
jQuery(document).ready(function($){
$('.accordion-container').hide();
//$('.accordion-toggle:first').addClass('active').next().show();
$('.accordion-toggle').click(function(){
if($(this).next().not(':hidden')) {
$('.accordion-toggle').removeClass('active').next().slideUp();
}
if($(this).next().is(':hidden')) {
$('.accordion-toggle').removeClass('active').next().slideUp();
$(this).toggleClass('active').next().slideDown();
}
return false; // Prevent the browser jump to the link anchor
});
});
預先感謝您:)
th爲你答案,請你告訴我在代碼中究竟在哪裏添加window.scrollTo(0,0); – user3019325
@ user3019325我添加了更多代碼。我不是100%確定你想怎麼做,所以請稍微玩一下,你馬上就會知道。 – Kehlan
再次感謝你,它的工作,但現在它帶我到整個頁面的頂部,我只希望它把我帶到活躍的手風琴的頂部。 – user3019325