title: How to run a function in jquery
body: <p>I'm a programming newbie, and I can't figure out how to store a function in JQuery and run in it multiple places. </p>
  
  <p>I have:</p>
  
  <pre><code>$(function () {
    $("div.class").click(function(){
      //Doo something
  
    });
  
    $("div.secondclass").click(function(){
      //Doo something
    });
  
  });
  </code></pre>
  
  <p>Now the 2 "//Doo somethings" are the same, and I don't want to write the same code again.</p>
  
  <p>If I put:</p>
  
  <pre><code>$(function () {
  
    function doosomething ()
    {
      //Doo something
    }
  
    $("div.class").click(doosomething);
  
    $("div.secondclass").click(doosomething);
  
  });
  </code></pre>
  
  <p>That would run the function on page load, rather than only when it clicks.</p>
  
  <p>How do I do this correctly?</p>
  
  <p>Thanks!</p>