Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. <a href="#id">See chapter ID</a>
  2.  
  3. <h2 id="chapter1">Chapter 1</h2>
  4. <p>Your paragraphs</p>
  5. <p> ... </p>
  6. <a href="#chapter2">See chapter 2</a>
  7.  
  8. <h2 id="chapter2">Chapter 2</h2>
  9. <p>Your paragraphs</p>
  10. <p> ... </p>
  11. <a href="#chapter1">See chapter 1</a>
  12.  
  13. $(document).ready(function() {
  14.  
  15. var link = $('#linkId');
  16.  
  17. var chapter = $('#chapterId');
  18. var position = chapter.position(); // according to jQuery api
  19. var offsetTop = position.top; // this should be the absolute offset of the page's top
  20.  
  21. // Calls the tocify method on your HTML elements.
  22. link.tocify();
  23. chapter.tocify();
  24.  
  25. //Call the tocify method with options
  26. link.tocify({
  27. showEffect: "fadeIn"
  28. scrollTo: offsetTop,
  29. smoothScroll: false
  30. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement