jquery怎么限制鼠标只能在div内移动?超过div的范围时,鼠标不能移动。
这个有点类似于 ,限制范围拖拽 。
也不知道 你是 想怎么限制 。是 移出就 提示还是什么 。
你或许 可以 改变思路 ,就是 移出 div 就 禁用鼠标 共能 这样也可以 。或者隐藏 鼠标 曲线 救国
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>js限制鼠标范围</title>
<style>
* {
margin: 0;
padding: 0;
}
.box {
position: absolute;
width: 100%;
height: 100%;
}
.class {
width: 400px;
height: 400px;
background: red;
}
</style>
</head>
<body>
<div class="box">
<div class="class">
</div>
</div>
</body>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>
let box = document.getElementsByClassName("box")[0];
$(".class").mouseenter(function () {
$("body").css({ "cursor": "auto" }); //显示鼠标
});
$(".class").mouseleave(function () {
$("body").css({ "cursor": "none" }); //隐藏鼠标
// alert("移出")
});
</script>
</html>
https://blog.csdn.net/weixin_44599931/article/details/117073530
你这jq管的有点宽了,window不同意
AtiveX应该可以,chrome应该没那么大权限