title: Scroll to top of document with jQuery not working correct
body: <p>I am building a smartphone app (iOS) with jQuery. I have 2 divs, one displays a list of events, the other just one event. This is how they look:</p>
  
  <pre><code>&lt;div id="output"&gt;
  
              &lt;/div&gt;
  &lt;div id="single" style="background-color: red;"&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>First single is hidden on document.ready.</p>
  
  <p>When scrolling down the page and clicking an event it shows #single and hides #output. Now, problem is, it is keeping the current page 'location' for the x + y values rather than going to the top as it would with a new page, so the page appears blank, but the content is out of page view (and cannot scroll). This is how I attempted to bring the document to the top:</p>
  
  <pre><code>function showSingle(itemId){
  
                  $('#output').hide();
                  $('#single').show();
      $("#single").scrollTop(0);
  /* ajax */
  }
  </code></pre>
  
  <p>This however does not bring it to the top, have I made an error? Thanks</p>
  
  <p>EDIT:</p>
  
  <p>this is before I click: imgur.com/Mitlp and this is after click: imgur.com/873pO</p>
  
  <p>It should look like: <a href="http://imgur.com/nPGU8" rel="nofollow">http://imgur.com/nPGU8</a></p>
  
  <p>Second Edit: AJAX inside of the function</p>
  
  <pre><code>$.ajax({
                          url: 'http://dev.24323423.co.uk/getSingle.php',
                          dataType: 'jsonp',
                          data: { dbId: itemId },
                          jsonp: 'jsoncallbackSingle',
                          timeout: 8000,
                          success: function(data, status){
                              $.each(data, function(i,item){ 
                                  var linkedPageSingle = '&lt;p&gt;&lt;a href="#" onClick="homePage(1)"&gt;Back&lt;/a&gt;&lt;/p&gt;&lt;h2&gt;'+item.eventName+'&lt;/h2&gt;'
                                      + '&lt;p&gt;Description: '+item.description+'&lt;/p&gt;&lt;p&gt;Type: '
                                      + item.type+'&lt;/p&gt;&lt;p id="pageid"&gt;'+item.id+'&lt;/p&gt;';
  
                                  $('#single').append(linkedPageSingle);
                              });
                          },
  
                          error: function(){
                              $('#single').text('There was an error loading the data.');
                          }
  
                      });
  </code></pre>