I have 3 buttons <input type="submit" name="submitButton" value="something">. Then i check the event with $(".form_name").submit(function(e) { and i would like to check which of the 3 buttons have been clicked and to alert the user of the action and return false if the user wishes to not go through with the action.
How do i check which of these buttons have been clicked?
event.targetmight help. Another workaround is to have the three buttons fire events, and make their event handler do the submission. In that sense there is no guesswork.—
Personally I would first make sure that the three buttons have identifiers, plausibly tucked within with
$(element).datalines, or custom HTML attributes (oh, don’t use special classes!), and have the event handler check$(event.target).data(key)or$(event.target).attr(key)to find out more information related to the caller. I would then map the form’s submit event also to this handler, so everything is processed from one place.