如何在鼠标移动之前动态更改光标样式时更改光标 [英] How to get cursor to change before mouse moves when changing the cursor style dynamically

查看:146
本文介绍了如何在鼠标移动之前动态更改光标样式时更改光标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当项目被选中时,通过设置node.style.cursor ='foo'来动态更改我的光标。看来我的光标在鼠标移动像素之前不会改变。

I'm changing my cursor dynamically by setting node.style.cursor = 'foo' when an item becomes selected. It seems that my cursor doesn't change until the mouse moves a pixel.

有没有办法让浏览器立即更改它?

Is there a way to tell the browser to change it immediately?

推荐答案

您可以尝试使用jQuery。

You can try with jQuery.

$(node).css('cursor', 'wait');

或动态更改类别。

css将是:

span.auto {cursor:auto}
span.wait {cursor:wait}

javascript将是:

The javascript will be:

$(node).removeClass('auto');
$(node).addClass('wait);

这篇关于如何在鼠标移动之前动态更改光标样式时更改光标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆