jQuery toggleClass example

Toggle class name on click in jQuery

by ChrisStanyon

HTML

<form id="registration" action="https://google.com/search">
  <input type="text" name="q" />
  <button type="submit" name="submit"><!-- Change this to name="submit" to see it fails -->
    Submit
  </button>
</form>

JavaScript

$(function() {

  $('#registration').submit(function(e) {
    e.preventDefault()
    alert("submitted"+$(this).serialize())
  });
});