使用 JS 修改提交按钮的处理状态

发布时间: 2019-08-27 13:24:13 作者: 大象笔记

代码

$('#email_submit').prop('disabled', true);
$('#email_submit').attr('style', 'background: grey !important');
$('*').css('cursor', 'progress');

$('#email_submit').prop('disabled', false);
$('#email_submit').attr('style', 'background: #e40013 !important');
$('*').css('cursor', 'default');

修改鼠标样式为“处理中”

$("body").css("cursor", "progress");

这个效果还能更好一些,因为提交之后,如果鼠标移动到输入框上,可能变更鼠标的样式。 最好是所有元素的鼠标样式都修改掉

$('*').css('cursor', 'progress');

jquery 通过 css 修改 important 样式无效

需要使用修改 style 属性的方式

$('#email_submit').attr('style', 'background: grey !important');
我是一名山东烟台的开发者,联系作者