滚动监听



介绍

滚动监听能让你在页面滚动到适当的位置时监听元素也能指示在适当的位置。还是右边的导航,最好的例子。

结构


  <div class="row">
    <div class="col s12 m9 l10">
    <div id="introduction" class="section scrollspy">
    <p>Content </p>
  </div>

  <div id="structure" class="section scrollspy">
    <p>Content </p>
  </div>

  <div id="initialization" class="section scrollspy">
    <p>Content </p>
  </div>
  </div>
    <div class="col hide-on-small-only m3 l2">
    <ul class="section table-of-contents">
      <li><a href="#introduction">Introduction</a></li>
      <li><a href="#structure">Structure</a></li>
      <li><a href="#initialization">Intialization</a></li>
    </ul>
    </div>
  </div>
        

初始化


  $(document).ready(function(){
    $('.scrollspy').scrollSpy();
  });