title: Click on a div to toggle a checkbox inside of it using javascript
body: <p>This seems to be a simple problem, but I dont use alot of javascript.</p>
  
  <p>I have a div, with a checkbox in it, and would like the whole div to toggle the checkbox. This is what I have so far:</p>
  
  <pre><code>&lt;div style="padding: 2em; border: 1px solid"
       onClick="if (document.getElementById('cb').checked) document.getElementById('cb').checked=false; else document.getElementById('cb').checked=true;"&gt;
    &lt;input name="cb" id="cb" type="checkbox"&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Only problem is when you click the actual checkbox, it get toggled twice, and therefore doesn't change.</p>
  
  <p>Any ideas?</p>