我在网页上有一个 asp.net 按钮。
OnClientClick 代码禁用该按钮,以便用户不能多次提交。它还将按钮的文本更改为“请稍候...”
到目前为止一切都很好!
麻烦的是,因为它正在被禁用,所以“请稍候......”文本看起来很垃圾......我如何设置按钮的样式,以便即使它被禁用,它看起来也可以在 javascript 中启用。
<script type="text/javascript">
function btnSubmit_ClientClick(Client) {
var ok = Page_ClientValidate();
if (ok) {
Client.style.color = 'White';
Client.style.backgroundColor = '#9A4D9E';
Client.value = 'Please wait...';
Client.disabled = true;
}
}
</script>
编辑开始:
这是启用的按钮:
这是禁用的按钮:
...如您所见,文字是灰色和白色的?
为了更清楚,@user503034 建议在 CSS 中使用 [disabled]。这是我的代码,但我仍然有同样的问题:
button[disabled]:active, button[disabled], input[type="reset"][disabled]:active, input[type="reset"][disabled], input[type="button"][disabled]:active, input[type="button"][disabled], select[disabled] > input[type="button"], select[disabled] > input[type="button"]:active, input[type="submit"][disabled]:active, input[type="submit"][disabled]
{
color: Green;
background-color: #9A4D9E;
cursor: default;
}