-5
  • I want to get onclick of page position(x and y) along with scroll values if the page got any scrolls
  • And also want the below jquery code as javascript code:

     $("#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>
4

1 回答 1

1

尝试类似的东西

Discalimer:不确定 IE

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;
}

演示:小提琴

于 2013-06-04T12:00:35.010 回答