title: How to call jquery function on button click?
body: <p>I am creating a small college project in PHP where I want to submit a form without refresh. I am using the following code, but it is not working as I expected.</p>
  
  <p><strong>usercss/demo.js</strong></p>
  
  <pre><code>function newleadentryform(){
  
  document.getElementById('RightPaneContainerDiv').innerHTML="&lt;div id='leadgenerationformdiv'&gt;"+
  "&lt;form  id='form' 'action='#'&gt;"+
  "&lt;table width='352' border='0' class='CSSTableGenerator' style='width: 45%;'&gt;"+
  "&lt;tr&gt;"+
  "&lt;td&gt;&amp;nbsp&lt;/td&gt;"+
  "&lt;td&gt;&amp;nbsp;&lt;/td&gt;"+
  "&lt;/tr&gt;"+
    "&lt;tr&gt;"+
      "&lt;td class='leadgenerationformcss'&gt;Lead Owner&lt;/td&gt;"+
      "&lt;td&gt;&lt;input name='leadowner' type='text' class='leadgenerationtextboxcss' id='leadowner' /&gt;&lt;/td&gt;"+
    "&lt;/tr&gt;"+
  "&lt;tr&gt;"+
      "&lt;td&gt;"+
      "&lt;input type='button' id='submit'  name='submit' value='Update' onclick='leadgenerationformvalidation()'/&gt;"+
      "&lt;/td&gt;"+
      "&lt;td&gt;&lt;input type='reset' value='reset'&gt;&lt;/td&gt;"+
    "&lt;/tr&gt;"+
  "&lt;/table&gt;"+
  "&lt;/form&gt;"+
  "&lt;/div&gt;&lt;!-- leadgenerationformdiv--&gt;";  
  
  }
  </code></pre>
  
  <p><strong>index.php</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Examples of using jQuery Alerts&lt;/title&gt;
          &lt;script src="jquery.js" type="text/javascript"&gt;&lt;/script&gt;
          &lt;script src="jquery.ui.draggable.js" type="text/javascript"&gt;&lt;/script&gt;
  
          &lt;script src="jquery.alerts.js" type="text/javascript"&gt;&lt;/script&gt;
          &lt;link href="jquery.alerts.css" rel="stylesheet" type="text/css" media="screen" /&gt;
  
          &lt;!-- Example script --&gt;
          &lt;script type="text/javascript"&gt;
              $(document).ready( function() {
                  $("#submit").click( function() {
                      jAlert('Example of a basic alert box in jquery', 'jquery basic alert box');
                  });
              });
          &lt;/script&gt;
          &lt;script src="userjs/demo.js"&gt;&lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
      &lt;/body&gt;
      &lt;a href="#" class="headerAnchorClass" onclick='newleadentryform()'&gt;New Lead&lt;/a&gt;
      &lt;/p&gt;
      &lt;div id="RightPaneContainerDiv" style=" float: left; margin-left: 11px; overflow-y: auto; height: 90vh;"&gt;
      &lt;/div&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>When I click on "New Lead" -link, a form should open, which contains a text field and an "Update" button, which should then submit the form without refresh.</p>
  
  <p>How can I achieve what I am trying to do here? Thanks in advance.</p>