更新时间:2023-12-05 07:55:04
在脚本开头的某个地方(可能是按钮的click事件),将按钮的disabled属性设置为true:
Somewhere at the beginning of your script (probably on the button's click event), set the button's disabled attribute to true:
$("#mybutton").attr("disabled", true);
然后,完成后,删除该属性:
Then, when complete, remove that attribute:
$("#mybutton").removeAttr("disabled");
编辑:
如果你想得到(略微)幻想,在你工作的时候改变按钮的文字。如果是图像按钮,您可以将src更改为友好的请稍候消息。以下是按钮文本版本的示例:
If you want to get (slightly) fancy, change the text of the button while you're doing the work. If it's an image button, you can change the src to a friendly "please wait" message. Here's an example of the button text version:
$("#mybutton").click(function() {
var origVal = $(this).attr("value");
$(this).attr("value", "Please wait...");
$(this).attr("disabled", true);
//Do your processing.
$(this).removeAttr("disabled");
$(this).attr("value", origVal);
});