title: what am i doing wrong with the button?
body: <p>i want to set alert on button click but when i click the button nothing happens please check.
  even if i click the button there should be an alert if the box is check then foo or if it is not checked then bar but nothing is happening on button click !-- begin snippet: js hide: false console: true babel: false --></p>
  
  <pre class="lang-js prettyprint-override"><code>function myFunction(){
  if (document.getElementById('foo').checked) {
      alert('foo');
  } else {
      alert('bar');
  }
  }
  </code></pre>
  
  <pre class="lang-html prettyprint-override"><code>&lt;input type="radio" name="zing" id="foo" /&gt;
  &lt;input type="radio" name="zing" id="bar"/&gt;
  &lt;button onclick="myFunction()"&gt;
  hello
  &lt;/button&gt;
  </code></pre>