I have two buttons in a form and want to check which one was clicked. Everything works fine with radioButtons:
if($("input[@name='class']:checked").val() == 'A')
On simple submit button everything crash.
Thanks!
Show activity on this post. jQuery(':button'). click(function () { if (this.id == 'button1') { alert('Button 1 was clicked'); } else if (this.id == 'button2') { alert('Button 2 was clicked'); } });
Present Code click(function (e) { // Prevent button from double click var isPageValid = Page_ClientValidate(); if (isPageValid) { if (isOperationInProgress == noIndicator) { isOperationInProgress = yesIndicator; } else { e. preventDefault(); } } }); });
jQuery click() Method The click event occurs when an element is clicked. The click() method triggers the click event, or attaches a function to run when a click event occurs.
$('#submit1, #submit2').click(function () { if (this.id == 'submit1') { alert('Submit 1 clicked'); } else if (this.id == 'submit2') { alert('Submit 2 clicked'); } });
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