我有一个内容很长的 Accordion 菜单。所以我需要在 Accordion 内容打开时实现滑动效果。
目前,如果您打开前两个菜单项,那么最后一个元素会显示视口(viewport)下方的内容,因此我需要为 Accordion 菜单项设置向上滑动效果。
这是我的代码
$(document).ready(function () {
//Accordion
$(".menu_body").hide();
//toggle the componenet with class menu_body
$(".menu_head").click(function(){
$(this).next(".menu_body").slideToggle(400);
var plusmin;
plusmin = $(this).children(".plusminus").text();
$(this).children("span.down-arrow").toggleClass("up-arrow");
});
});
最佳答案
看看这个,这是预期的吗?
$(document).ready(function () {
//Accordion
$(".menu_body").hide();
//toggle the componenet with class menu_body
$(".menu_head").click(function(){
$(".menu_body").each(function (event){
$(".menu_body").hide();
});
$(this).next(".menu_body").slideToggle(400);
var plusmin;
plusmin = $(this).children(".plusminus").text();
$(this).children("span.down-arrow").toggleClass("up-arrow");
});
});
关于javascript - 将 Accordion 滑动到浏览器顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20367293/