title: Keep button from submitting form Javascript
body: <p>I'm learning JavaScript and am unable to make a button inside of a form that doesn't submit the form. There is a similar question <a href="https://stackoverflow.com/questions/932653/how-to-prevent-buttons-from-submitting-forms">here</a> but the most popular answer to specify <code>type="button"</code> doesn't work in my case and other answers involve jQuery, which I would like to leave out for now.</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html&gt;
  &lt;head&gt;
  &lt;script type="text/javascript"&gt;
          function submit(){
                  alert("Yo")
          }
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;form name="myForm" onsubmit="submit()"&gt;
          &lt;input type="button" value="Submit!" onClick="submit()" /&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>