Jquery,得到div重叠的mousemove事件

时间:2011-11-28 05:36:54

标签: jquery mousemove overlapping

请帮帮我。

我需要能够在带有滚动条的div中的图像上绘制一个矩形。

当鼠标点击矩形区域时使用IE 9或firefox 停止将mousemove事件发送到图像。

即使div在图像上方,我如何使mousemove事件正常工作?

$("#AnImage")
.mousedown(function(event)
{
//Set the start point and create the new div as a marker. Start the creating process.
})
.mousemove(function(event)
{
//Moves according to the initial point, set the with and height of the marker
})
.mouseup(function(event){
//Stop the creating process. A new Rectangle is over the image.
});

感谢。

1 个答案:

答案 0 :(得分:1)

您可以使用pointer-events CSS属性 - 如果您想要在图片上绘制<div>内的任何项目。

#AnImage {
  pointer-events: none;
}

有关该属性的更多信息:hereherehere