并且还希望将以下jquery代码作为javascript代码:
$("#drag").mouseup(function(event){
var x = event.pageX - $(this).offset().left;
var y = event.pageY - $(this).offset().top;
$("#pos").html(x + ', ' + y); });
<div id="drag" style="width:2000px;height:2000px;border:1px solid #000; top:100px; left:100px; position:absolute; background-color: #AACCEE">
</div>
答案 0 :(得分:1)
尝试类似
的内容免责声明:不确定IT
document.getElementById('drag').onmouseup = function(event){
var event = event || window.event;
var x = event.pageX - this.offsetLeft;
var y = event.pageY - this.offsetTop;
document.getElementById('pos').innerHTML = x + ', ' + y;
}
演示:Fiddle