title: onclick assigned function with parameters
body: <p>I'm not sure if this has been asked before because I don't know what it's called.</p>
  
  <p>But why wouldn't a method like this work? Below is just a general example</p>
  
  <pre><code>&lt;script&gt;
  document.getElementById('main_div').onclick=clickie(argument1,argument2);
  
  function clickie(parameter1,parameter2){
   //code here
  }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>The code above would work fine if the event handler was assigned without parameters, but with parameters, it doesn't work. I think I read online that to overcome this problem, you could use closures. I'm assuming it's because of the parentheses ( ) that is calling the function immediately instead of assigning it to the event? </p>