Browse Source

静态信息锚点

zhangxc 6 years ago
parent
commit
acad6cfe38
1 changed files with 3 additions and 3 deletions
  1. 3 3
      src/js/information.js

+ 3 - 3
src/js/information.js

@@ -34,9 +34,9 @@ function getInfomation() {
     for (var i = 0; i < list.length; i++) {
       item = list[i];
       item.content = item.content.replace(/{imageUrlPrefix}/g, imageUrlPrefix);
-      anchors = '<li><i></i><a href="#' + item.id +
+      anchors = '<li><i></i><a href="#' + item.title +
         '">' + item.title + '</a></li><li class="anchor-line"></li>';
-      str = '<div class="title"><h2 id="' + item.id +
+      str = '<div class="title"><h2 id="' + item.title +
         '">'
       if (getUrlArgObject('type') == 8) {
         str += '【' + item.title + '】'
@@ -57,7 +57,7 @@ function getInfomation() {
       var scrollTop = $('.infos').scrollTop()
       var divHeight = 0;
       for (var i = 0; i < list.length; i++) {
-        divHeight = divHeight + parseInt($('#' + list[i].id).css('height')) + parseInt($('#' + list[i].id).parent().next().css('height')) + 40
+        divHeight = divHeight + parseInt($('#' + list[i].title).css('height')) + parseInt($('#' + list[i].title).parent().next().css('height')) + 40
         if (divHeight > scrollTop) {
           var anchor = 2 * i;
           $('.anchors ul').children().eq(anchor).addClass('active').siblings().removeClass('active');