问题
How can I change the mouse cursor in Javascript or in jQuery ? I know it's a very classic question, but very strangely this JSFiddle doesn't work : http://jsfiddle.net/2Qffw/.
Here is the code :
$('body').css('cursor','pointer');
document.body.style.cursor = "pointer";
回答1:
Do it in both html
and body
:
$('html,body').css('cursor','crosshair');
http://jsfiddle.net/2Qffw/3/
回答2:
It does work, but you had an empty body.
http://jsfiddle.net/z6mhH/
HTML
<body>
asdasdasdasdads
</body>
JS
document.body.style.cursor = "crosshair";
回答3:
document.getElementById("mydiv").style.cursor="move";
回答4:
in Javascript, you can do it, you just have to use void 0;
at the end of document.body.style.cursor = "crosshair";
, so at the end, it should look like this: document.body.style.cursor = "crosshair"; void 0;
.
来源:https://stackoverflow.com/questions/17414034/change-mouse-cursor-in-javascript-or-jquery