[英]Making accordion with setting up the scrollTop - offset animation 0 on click… doesn't work well when data is expened
我正在通过设置scrollTop-单击时偏移动画0来制作手风琴。
如果在点击之前关闭所有内容,则一切正常。 但是,如果有任何选项卡数据特别用在顶部手风琴上。...scrollTop代码将整个内容向上推并隐藏在顶部窗口区域中...
而且我想在所有标签关闭时重置默认位置。
任何帮助,不胜感激! 提前致谢。
这是代码和小提琴URL:
http://jsfiddle.net/mufeedahmad/SKB3Z/10/
var showContainer = $('ul#ui-collapsible div.collapsible-content'),
showClickHandler = $('ul#ui-collapsible li > a');
$.fn.offsetscroll = function(){
$(this).click(function(){
$('html, body').animate({
scrollTop: $( $(this).attr('href') ).offset().top
}, 500);
return false;
});
}
showClickHandler.offsetscroll();
$.fn.myClickMethod = function(){
var $this = $(this);
if($this.parent().hasClass('active')){
$this.parent().removeClass('active');
$this.next().slideUp();
}
else{
$('ul#ui-collapsible .active').removeClass('active');
showContainer.slideUp();
$this.next().slideDown(500);
$this.parent().addClass('active');
}
}
showClickHandler.click(function(){
$(this).myClickMethod();
});
采用
scrollTop: $( $(this).attr('href') ).scrollTop()
代替
scrollTop: $( $(this).attr('href') ).offset().top
这将解决您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.