diff options
author | amazingrise <8315221+AmazingRise@users.noreply.github.com> | 2020-03-15 20:33:54 +0300 |
---|---|---|
committer | amazingrise <8315221+AmazingRise@users.noreply.github.com> | 2020-03-15 20:33:54 +0300 |
commit | 8329b73ee171ec0a6f8617f05080e4bb8860ab14 (patch) | |
tree | 7cd54031215bb435185333d6358cffcabdbe0343 /static | |
parent | 6c25e7f47b1c0823d64df33b35da9cf1b5abc65e (diff) |
Fix some bugs of Table of Contents.
Diffstat (limited to 'static')
-rw-r--r-- | static/js/toc.js | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/static/js/toc.js b/static/js/toc.js index 2c5b9fb..075a09e 100644 --- a/static/js/toc.js +++ b/static/js/toc.js @@ -1,9 +1,13 @@ $().ready(function(){ + var elems = $(":header"); + if (elems.length == 0) { + return; + } $(window).bind('scroll', function() { var currentTop = $(window).scrollTop(); var currentBottom = $(window).scrollTop() + $(window).height(); var pageBottom = $('#EOF').offset().top; - var elems = $(":header"); + elems.each(function(idx){ var elemTop = $(this).offset().top; var id = $(this).attr('id'); |