jQuery 如何用jquery隐藏鼠标光标

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4437204/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 17:16:34  来源:igfitidea点击:

How to hide mouse cursor with jquery

jquerywebcursorhide

提问by KillerFish

How to hide mouse cursor with jquery in entire webpage. I tried this

如何在整个网页中使用 jquery 隐藏鼠标光标。我试过这个

$(document).ready(function(){
        $(body).css({
           'cursor' : 'none'
        });
});

But this is not working in all the browsers. Is there any plugin to implement this.

但这并不适用于所有浏览器。是否有任何插件来实现这一点。

Thanks in Advance.

提前致谢。

回答by Brian Rose

$('body').css('cursor', 'none');

回答by Ben Everard

I bet it has nothing to do with the jQuery method, but in fact the CSS for your page.

我敢打赌它与 jQuery 方法无关,但实际上与您页面的 CSS 无关。

Make sure (using firebug) that the body element is actually visible on the page, the contents might because the overflow is set to auto by default, but you'll also need to set the body height and width to 100% to ensure that when you're mouse moves across the screen it actually invokes body.mouseover()

确保(使用 firebug) body 元素在页面上实际可见,内容可能是因为默认情况下溢出设置为 auto,但您还需要将 body 的高度和宽度设置为 100% 以确保当你的鼠标在屏幕上移动它实际上调用了 body.mouseover()

Here's a working example ? http://jsfiddle.net/Ilmv/XQmqe/

这是一个工作示例?http://jsfiddle.net/Ilmv/XQmqe/

回答by Manny

Another solution could be done by loading custom transparent ICO/PNG file as cursor.

另一种解决方案可以通过加载自定义透明 ICO/PNG 文件作为光标来完成。

cursor: url('my-transparent-cursor.ico');

So now user has cursor but is transparent, invisible. Just my two cents.

所以现在用户有光标但是是透明的,不可见的。只有我的两分钱。

回答by PseudoNinja

What about using a transparent div overlay (div with an absolute position, 100% width and height, and positive z-index) with cursor set to none. Then use jQuery to toggle it on/off?

使用透明 div 覆盖(具有绝对位置、100% 宽度和高度以及正 z-index 的 div)并将光标设置为 none 怎么样。然后使用 jQuery 打开/关闭它?

回答by Jamie

Should definitely work in all browsers. Check in firebug which elements the cursor occurs on and see if it has an explicit "cursor: pointer;" or equivalent setting.

绝对应该在所有浏览器中工作。检查萤火虫光标出现在哪些元素上,看看它是否有一个明确的“光标:指针;” 或等效设置。

回答by Joko Wandiro

I think u can make overlay with div element when page is ready you set visibility to block.

我认为你可以在页面准备好时使用 div 元素进行叠加,将可见性设置为阻止。

HTML CODE:

HTML代码:

<div>Test</div>

CSS CODE:

代码:

div {
  position: fixed;
  left: 0%;
  width: 100%;
  height: 100%;
  cursor: none;
  visibility: block;
}

hope it can help u.. I test it on jsfiddleand it works for me

希望它可以帮助ü..我测试它的jsfiddle和它的作品对我来说

Maybe it what u find

也许它是你发现的