roshan
roshan

Reputation: 83

how to get cancel button event?

I have a JQGrid that has an 'Add' button. In my grid, when the 'Add' button is clicked, a single 'Add' form is opened. The 'Add' form has two default buttons: 'Submit' And 'Cancel'. I want to execute some code on the click event of the Cancel button. I'm not sure how to handle this does anyone have any suggestions?

Upvotes: 1

Views: 1330

Answers (1)

ORION
ORION

Reputation: 2411

If I understand you correctly, you want to execute a jquery function upon clicking the CANCEL button. This is what I would do:

<input type="button" value="Cancel" id="btnCancel" />

 $('#btnCancel').on('click', function() {
  //DO STUFF
 });

OR

$('#btnCancel').click(function() {
 //DO STUFF
});

OR you could put a function call on the input itself:

function myFunction() {
 //DO STUFF
}

<input type="button" value="Cancel" id="btnCancel" onclick="return myFunction();" />

Upvotes: 1

Related Questions