我使用了这段代码,但它只适用于 Y 坐标
$('div').mousemove(function(e){
var x = Math.floor(e.pageX - $(this).offset().left);
var y = Math.floor(e.pageY - $(this).offset().top);
$('.status').html(x+' '+y);
});
X 坐标显示错误的值。
我使用了这段代码,但它只适用于 Y 坐标
$('div').mousemove(function(e){
var x = Math.floor(e.pageX - $(this).offset().left);
var y = Math.floor(e.pageY - $(this).offset().top);
$('.status').html(x+' '+y);
});
X 坐标显示错误的值。