title: Scroll to a div using jQuery
body: <p>so I have a page that has a fixed link bar on the side.  I'd like to scroll to the different divs.  Basically the page is just one long website, where I'd like to scroll to different divs using the menu box to the side.</p>
  <p>Here is the jQuery I have so far</p>
  <pre><code>$(document).ready(function() {
      $('#contactlink').click = function() {
          $(document).scrollTo('#contact');
      }
  });
  </code></pre>
  <p>The issue is it is automatically going to the contact div when it loads, then when I press the <code>#contactlink</code> in the menu it scrolls back to the top.</p>
  <p>EDIT: HTML</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;html lang=&quot;en&quot;&gt;
  
      &lt;head&gt;
      &lt;meta charset=&quot;utf-8&quot;&gt;
      
      &lt;!-- jQuery--&gt;
      &lt;script src = &quot;&lt;?php echo base_url() ?&gt;assets/js/jquery.js&quot;&gt;&lt;/script&gt;
      
      &lt;!-- .js file--&gt;
      &lt;script src = &quot;&lt;?php echo base_url() ?&gt;assets/js/pagetwo.js&quot;&gt;&lt;/script&gt;
  
      &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;&lt;?php echo base_url()?&gt;assets/css/reset.css&quot; /&gt;    
              
      &lt;!-- .css for page --&gt;
      &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;&lt;?php echo base_url()?&gt;assets/css/pagetwo.css&quot;/&gt;                       
      
      &lt;!-- page title--&gt;
      &lt;title&gt;&lt;!-- Insert Title --&gt;&lt;/title&gt;
      
  
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div id=&quot;container&quot;&gt;
      
          &lt;div id=&quot;sidebar&quot;&gt;
              &lt;ul&gt;
                  &lt;li&gt;&lt;a id = &quot;aboutlink&quot; href=&quot;#&quot;&gt;auck&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a id = &quot;peojectslink&quot; href=&quot;#&quot;&gt;Projects&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a id = &quot;resumelink&quot; href=&quot;#&quot;&gt;Resume&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a id = &quot;contactlink&quot; href=&quot;#&quot;&gt;Contact&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/div&gt;
          
          &lt;div id=&quot;content&quot;&gt;
              &lt;div class=&quot;&quot; id=&quot;about&quot;&gt;
                  &lt;p class=&quot;header&quot;&gt;uck&lt;/p&gt;
                  &lt;p class=&quot;info&quot;&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.&lt;/p&gt;
              &lt;/div&gt;
              &lt;div class=&quot;sections&quot;id=&quot;projects&quot;&gt;
                  &lt;p class = &quot;header&quot;&gt;Projects&lt;/p&gt;
                  &lt;p class=&quot;info&quot;&gt;Projects&lt;/p&gt;
              &lt;/div&gt;
              &lt;div class=&quot;sections&quot; id=&quot;resume&quot;&gt;
                  &lt;p class = &quot;header&quot;&gt;Resume&lt;/p&gt;
                  &lt;p class=&quot;info&quot;&gt;Resume&lt;/p&gt;
              &lt;/div&gt;
              &lt;div class=&quot;sections&quot; id=&quot;contacts&quot;&gt;
                  &lt;p class = &quot;header&quot;&gt;Contact&lt;/p&gt;
                  &lt;p class=&quot;info&quot;&gt;Contact&lt;/p&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>