单击按钮一次后禁用该按钮

bat*_*adi 3 javascript asp.net-mvc

在我的应用程序中,我需要在单击按钮后禁用该按钮,以便用户不应多次单击.APplication是MVC ASP.NET我在普通的asp.net应用程序中完成了这个.我尝试了下面的代码行,但它不起作用

提前致谢

编辑 我怎么能用javascript实现这个?

Phi*_*ale 7

我发现使用IE8(我不确定其他版本的IE),如果禁用click事件上的按钮,则无法提交表单.所以我提出了另一种解决方案.隐藏单击的按钮并在其中放置一个新的禁用按钮.这是代码:

$().ready(function() {
  $("someButtonSelector").click(function () {
    $(this).hide();
    $(this).after('<input type="button" disabled="disabled" value="' + $(this).val() + '" />');
    return true;
  });
});
Run Code Online (Sandbox Code Playgroud)