user3287550 user3287550 - 3 months ago 12
jQuery Question

How to get event that has fired the function?

Suppose that I've this:

<form onsubmit="Popup(this)">


when I press the
submit
button the
Popup
function is fired. How can I get the
submit
event and prevent it?

Popup: function(item)


Thanks.

Answer

try this:

function( item ) {
  alert( "Handler for .submit() called." );
  item.preventDefault();
  // rest of the code
}

OR

    $("#form_id").validate({
        submitHandler: function (form) {
            // do code
            return false;
    }})