title: Jquery With Button Onclick Function
body: <p>I'm just starting web development, and have a function loadTweets that pulls from another file and displays, and when I get rid of the button, and just run it directly as an anonymous function it works, however, for some reason the button does not work to call the function. </p>
  
  <p>Any help would be greatly appreciated, thanks! </p>
  
  <pre><code>&lt;html&gt;
    &lt;head&gt;
      &lt;script src="jquery.js"&gt;&lt;/script&gt;
      &lt;script src="data_generator.js"&gt;&lt;/script&gt;
  
    &lt;/head&gt;
    &lt;button type = "button" onclick="loadTweets"&gt; Load &lt;/button&gt;
    &lt;body&gt;
      &lt;script&gt;
        $(document).ready(function(){
          var loadTweets = function(){
            var $body = $('body');
            $body.html('');
            var index = streams.home.length - 1;
            while(index &gt;= 0){
              var tweet = streams.home[index];
              var $tweet = $('&lt;div&gt;&lt;/div&gt;');
              $tweet.text('@' + tweet.user + ': ' + tweet.message);
              $tweet.appendTo($body);
              index -= 1;
            }
          }
        });
      // });
  
  
  
      &lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>