title: How do I add an onclick function to a div in javascript?
body: <p>I have a piece of javascript is meant to add an onclick event to a div.</p>
  
  <p>The div looks like this:</p>
  
  <pre><code>&lt;div id="deck0" class="deck"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>And my javascript has:</p>
  
  <pre><code>var i = 1;
  document.getElementById('deck0').SetAttribute("onclick", "begin("+i+")");   
  </code></pre>
  
  <p>But I get this error:</p>
  
  <pre><code>Uncaught TypeError: Object #&lt;HTMLDivElement&gt; has no method 'SetAttribute' 
  </code></pre>
  
  <p>Am I doing it right, or is what I am trying to achieve not possible?</p>