如果光标位于元素之外,如何应用压缩光标

How to get the mousdown cursor to apply if cursor is outside of an element?

本文关键字:光标 何应用 应用 压缩 于元素 元素 如果      更新时间:2023-09-26

在这个小提琴中,你可以抓住黑框,然后拖拽一个圆圈

http://jsfiddle.net/S5AT6/

当用户抓住黑框时,如何显示鼠标向下光标(闭合手)而不是默认光标,但他们的光标在#marker元素之外和文档内部。

你去: 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

在文档就绪中添加了这个:

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

在鼠标按下功能中添加了以下内容:

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

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