JS获取鼠标在元素内的相对坐标

canvas.onmousemove = function(e){
	var rect = canvas.getBoundingClientRect();
	canvas.title = parseInt(e.x - rect.x) + ',' + parseInt(e.y - rect.top);
};

你可能感兴趣的:(JS,javascript)