Skip to content

Commit 30e4147

Browse files
committed
分类高亮
1 parent b01661e commit 30e4147

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

views/cates/list.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,24 @@ <h3 class="panel-title">
112112
var top = $(".category-index").offset().top
113113
var height = $(window).height() - 110 - 70
114114
var style = 'max-height:'+height+'px';
115-
if($(window).scrollTop() -15>=top){
115+
var scrollTop = $(window).scrollTop()
116+
if(scrollTop -15>=top){
116117
$(".category-index .panel-default").addClass("fixed")
117118
$(".category-index .panel-body").attr("style",style)
118119
}else{
119120
$(".category-index .panel-default").removeClass("fixed")
120121
$(".category-index .panel-body").attr("style",'')
121122
}
123+
console.log(scrollTop)
124+
var panels = $(".category-detail>.panel")
125+
126+
for (var i = 0; i < panels.length; i++) {
127+
if($(panels[i]).offset().top - scrollTop>=0){
128+
$(".category-index a").removeClass("active");
129+
$("[data-show="+$(panels[i]).attr("id")+"]").addClass("active");
130+
i=panels.length
131+
}
132+
}
122133
}
123134
$(".cate-item").tooltip();
124135
$(".category-index a").tooltip();

0 commit comments

Comments
 (0)