title: How to summit the form and delete html button in the 1 click using javascript
body: <p>In my code, I use javascript to send data to python(flask) and delete the button when it is successful. the code of the button is given below</p>
  <p>The result is that it sends the data to python and the backend function on python is work but the button is not be deleted. I write <em>alert(p)</em> in the <em>success:function</em> because I want to know whether the function is used or not and it alerts!!. I am really new to HTML and javascript. Please someone explain how it works and tell me how to solve it!</p>
  <pre class="lang-js prettyprint-override"><code>$(document).on('submit', '#todo-form2', function(e) {
    console.log('hello');
    e.preventDefault();
    $.ajax({
      type: 'POST',
      url: '/delete',
      data: {
        todo: $(&quot;#todo&quot;).val()
      },
      success: function() {
        var p = $(&quot;#todo&quot;).val()
        alert(p);
        var elem = document.getElementByName(p);
        elem.parentNode.removeChild(elem);
      }
    })
  });
  </code></pre>
  <pre class="lang-html prettyprint-override"><code>&lt;form method=&quot;post&quot; id=&quot;todo-form&quot;&gt;
    &lt;button class=&quot;primary&quot; name=&quot;560510531&quot; id=&quot;todo&quot; type=&quot;submit&quot; value=560510531&gt; 
      Accept 
      &lt;/button&gt;
  &lt;/form&gt;
  &lt;form method=&quot;post&quot; id=&quot;todo-form2&quot;&gt;
    &lt;button class=&quot;primary ghost&quot; name=&quot;560510531&quot; id=&quot;todo&quot; type=&quot;submit&quot; value=560510531&gt; 
      Deny 
      &lt;/button&gt;
  &lt;/form&gt;
  </code></pre>