I have a web page I'm working on with jQuery. I'm getting erratic behavior from some elements on my page: Every time a button, any button, on the page is clicked, the page refreshes.
The page must somehow be running some code that reloads that page any time a button is clicked.
I'm completely stumped trying to figure out where the code is getting bound to the click handler, so I would like to know if it is possible to enumerate, at run-time, a list of handlers attached to a button.
Update: After reading the answers given below, I changed a line in my page:
<button id="btnSaveAndContinue" class="button" tabindex="290">Save and Continue</button>
to this:
<input type='button' id="btnSaveAndContinue" class="button" tabindex="290" value='Save and Continue' />
This is the default behaviour of a button. If you want to change it, do something like this:
$("button selector").click( function(event) {
event.preventDefault();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With