问题
I want to disable button when user first click it so it must not save multiple record if a user have a slow connection. Im using asp.net mvc2
回答1:
$('#buttonId').click(function() {
$(this).attr('disabled', 'disabled');
});
Of course you have to adjust the selector.
回答2:
You can use jQuery's one(). With this, the event handler is executed only once. Inside the event handler you can disable or change the style.
Example from jQuery site:
$('#foo').one('click', function() {
alert('This will be displayed only once.');
});
来源:https://stackoverflow.com/questions/3573849/disable-button-when-first-click-in-jquery