是否可以找到用户点击图片的位置?
我有一张图片 - 用户可以点击图片。我正试图找到一种方法,如何在用户点击时获得该地点。
最佳答案
在点击图像时,您可以使用事件对象找到用户点击的坐标。
$("imageSelector").click(function(e){
var pos = $(this).position();
//The following are the x/y coordinates of the mouse click relative to image.
var x = e.pageX - pos.left;
var y = e.pageY - pos.top;
});
关于javascript - 获取图像中用户点击的部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6854220/