Javascript 如何使用 JQuery 更改光标的样式?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5932837/
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-23 19:34:24  来源:igfitidea点击:

How do I change the style of the cursor with JQuery?

javascriptjquerycursormouse

提问by user730569

I want to change the style of the cursor as if it were going over a link. How do I do this?

我想改变光标的样式,就好像它在链接上一样。我该怎么做呢?

回答by JohnP

Modify the CSS cursorvalue by using the css()method

cursor使用css()方法修改CSS值

$('#selector').css('cursor', 'pointer');

Demo : http://jsfiddle.net/jomanlk/H6Nta/

演示:http: //jsfiddle.net/jomanlk/H6Nta/

回答by kobe

you can play around with this

你可以玩这个

$('#divid').css('cursor','default');

for pointer

对于指针

$('#divid').css('cursor','pointer');

api

接口

http://api.jquery.com/css/

http://api.jquery.com/css/

回答by Gowri

using css

使用CSS

http://www.echoecho.com/csscursors.htm

http://www.echoecho.com/csscursors.htm

read here for different cursor styles

阅读此处了解不同的光标样式

and apply it

并应用它

$('#selector').css('cursor', 'value');

回答by Codemwnci

Cursors are handled by CSS. You need something like

游标由 CSS 处理。你需要类似的东西

$('#elementid').css('cursor', 'pointer');

or for old IE browsers

或用于旧的 IE 浏览器

$('#elementid').css('cursor', 'hand');