我有以下内容:
$(document)
.ajaxStart(function () {
$(this).css({ 'cursor': 'progress !important' })
})
.ajaxStop(function () {
$(this).css({ 'cursor': 'default !important' })
});
有没有办法可以将光标进度状态延长2秒。现在它来得太快,去得也太快了。换句话说,我想让光标更改为“进度”至少几秒钟。
最佳答案
编辑:
尝试使用window.setTimeout
。
var timer = null;
$(document)
.ajaxStart(function () {
if (timer) {
clearTimeout(timer);
}
$(this).css({ 'cursor': 'progress !important' });
})
.ajaxStop(function () {
timer = setTimeout(function() {
$(this).css({ 'cursor': 'default !important' });
}, 2000);
});
关于javascript - 如何为 .css 状态的更改添加延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12385398/