如果游标在元素之外,如何应用mousedown游标?

时间:2012-04-15 02:15:47

标签: javascript jquery

在这个小提琴中,你可以抓住并拖动黑框围绕一个圆圈

http://jsfiddle.net/S5AT6/

当用户抓住黑匣子但是他们的光标位于#marker元素之外且文档内部时,如何显示mousedown光标(closedhand)而不是默认光标。

2 个答案:

答案 0 :(得分:3)

你去了:Solution on jsFiddle

事情发生了变化:

<强> CSS

// removed the !important flag here
cursor: url(https://mail.google.com/mail/images/2/openhand.cur), default; 

// removed the div#marker here
.mouseDown {

<强> JS

在doc ready上添加了这个:

$(document).on('mouseup', function(event) {
    $('body').removeClass("mouseDown");
});

在你的mousedown函数中添加了这个:

$('body').addClass("mouseDown");

答案 1 :(得分:0)

只需将cursor样式应用于整个<html>即可。 Updated jsFiddle