-3

Hello I'm wondering if there is an alternative way to run JavaScript when a button is submitted without using the onsubmit event. Thx

  • If your intention is to get the value and not to submit the form , then you can use the sumit listener and return before the form is submitted – hop Apr 03 '13 at 18:36

1 Answers1

1

Yeah, give the button an ID, and utilize jQuery like this:

$("#target").click(function() {
  alert("Handler for .click() called.");
});

Code example from http://api.jquery.com/click/

You should use Google the next time more wisely. This is an easy one...

thomas
  • 2,580
  • 1
  • 22
  • 28