Given the following HTML fragment:
<form id="aspnetForm" onsubmit="alert('On Submit Run!'); return true;">
I need to remove/clear the handler for the onsubmit event and register my own using jQuery or any other flavor of JavaScript usage.
Given the following HTML fragment:
<form id="aspnetForm" onsubmit="alert('On Submit Run!'); return true;">
I need to remove/clear the handler for the onsubmit event and register my own using jQuery or any other flavor of JavaScript usage.
To do this without any libraries:
document.getElementById("aspnetForm").onsubmit = null;
For jQuery, off() removes all event handlers added by jQuery from it.
$('#aspnetForm').off();
Calling .off() with no arguments removes all handlers attached to the elements.