title: jquery scrollTo: TypeError undefined is not a function
body: <p>I have a list of horizontally stacked divs, with ids <code>pageContent1</code>, <code>pageContent2</code> and so on. I want to scroll to the next page on the right when the right arrow key is pressed, and to the previous page on the left when the left key is pressed. I'm using jquery's scrollTo method (<a href="http://lions-mark.com/jquery/scrollTo/" rel="nofollow">http://lions-mark.com/jquery/scrollTo/</a>). Here's the code:</p>
  
  <pre><code>var
      hp_first = 1,
      hp_last = $('.page').length,
      hp_curr = 1
  
  $(document).keydown(function(e) {
      switch(e.which) {
          case 37: //left
              if(window.hp_curr &gt; window.hp_first) {
                  $('body').scrollTo('#pageContainer' + --window.hp_curr)
              }
              break
  
          case 39: //right
              if(window.hp_curr &lt; window.hp_last) {
                  $('body').scrollTo('#pageContainer' + ++window.hp_curr)
              }
              break
  
          default: return
      }
      e.preventDefault()
  })
  </code></pre>
  
  <p>This gives me an error:</p>
  
  <pre><code>Uncaught TypeError: undefined is not a function VM1698:17(anonymous function) VM1698:17jQuery.event.dispatch notable-bootstrap.js:4676elemData.handle notable-bootstrap.js:4360
  </code></pre>
  
  <p>What am I doing wrong?</p>