我正在开发 MVC 项目,我在下面写了 javascript 代码来禁用我的按钮,实际上,按钮被禁用,但是按钮点击工作,如何解决它?
if (_isC == false) {
$('.crt').attr('disabled', true);
return false;
}
<a href="createnew">
@Html.ActionLink("Add New Record", "myIndex", "my", new { A = "New" }, new { Class = "btn btn-primary page-scroll crt", style = "top:50px; margin-left:168px;width:120px;text-indent:-5px; position:relative;", })
</a>
答案 0 :(得分:1)
由于Html.ActionLink
将创建一个锚元素,您应该绑定点击处理程序
$('.crt').on('click', function(){
return _isC; //Cancels event when _isC is false
});