javascript - same function for two buttons in jQuery -


I have two buttons: btnAdd and btnUpdate . I have written a jquery function for the button btnUpdate to validate some fields in the web page:

  $ (function () {$ ('# & lt ;% = BtnUpdate.ClientID% & gt; '). Click (function () {code here});});  

I want to do the same thing when btnAdd is clicked. So I have to rewrite the same function for BTNAD. Is there any other way to avoid this?

(If I type a javascript function and call the same function in the button click event of both buttons, then okay. But is there any way to use jQuery?)

< / Div>

Select two buttons separated by commas: ("# add, #update"). Click here ... This appears in your code:

  $ (function () {$ ('# & lt;% = btnUpdate.ClientID% & gt ;, # Click & lt;% = btn.ClickEdit% & Gt; '). Click (function () {code here});});  

Comments