Is there a way to tell Chrome web debugger to show the current mouse position in page coordinates?

后端 未结 3 1130
不思量自难忘°
不思量自难忘° 2021-01-29 21:18

I often debug my javascript code using the Chrome web debugger. In the elements tab, hovering over an element show a tooltip with a few pieces of information, including the widt

3条回答
  •  伪装坚强ぢ
    2021-01-29 22:18

    You could type this into the console,

    document.onmousemove = function(e){
    var x = e.pageX;
    var y = e.pageY;
    e.target.title = "X is "+x+" and Y is "+y;
    };
    

    This will give you mouse position on mouse move in the element tooltip.

提交回复
热议问题