MouseEvent offsetX 属性
实例
Click inside a DIV and output the coordinates of the click, relative to the DIV element:
var x = event.offsetX;
亲自试一试 »
页面下方有更多实例。
定义和用法
offsetX
property returns the x-coordinate
of the mouse pointer, relative to the target element.
提示: To get the y-coordinate, use the offsetY property.
注释: 该属性是只读的。
浏览器支持
属性 | |||||
---|---|---|---|---|---|
offsetX | Yes | 6 | 39 | Yes | Yes |
语法
event.offsetX
技术细节
返回值: | A Number, representing the horizontal coordinate of the mouse pointer, in pixels |
---|
相关页面
MouseEvent: offsetY Property
MouseEvent: clientX Property
MouseEvent: clientY Property
MouseEvent: screenX Property
MouseEvent: screenY Property