JSFiddle - React, Tailwind, and code Playground

by f1sherman

HTML

<div>
    Clicking the submit button repeatedly should toggle back and forth between form1 and form2.  However, in IE7 and IE8 on the 3rd click the form is actually submitted.
</div>
<br>
<div id='container'>
  <form id='form1' method=post>
    form1
      
    <input type=submit />
  </form>
</div>

JavaScript

var form1 = null;

$(document).on('submit', '#form1', function(e) {
  e.preventDefault();

  form1 = $('#container').html();
  
  $('#container').html(
    "<form id='form2' method=post>" +
    "  form2" +
    "  <input type=submit />" +
    "</form>"
  );
  
});
$(document).on('submit', '#form2', function(e) {
  e.preventDefault();

  $('#container').html(form1);
});