Return whether the user scrolls left or right:
function myFunction(event) {
var x = event.deltaX;
}
Try it Yourself »
The deltaX
property returns a positive value when scrolling to the right, and a negative value when scrolling to the left, otherwise 0.
Note: Most mouse devices do not have the ability to scroll left and right, and will always return 0.
Note: This property is read-only.
event.deltaX
Return Value: | A Double, indicating the scrolling direction of the mouse wheel |
---|
HTML DOM reference: WheelEvent deltaY Property
event.deltaX
is a DOM Level 4 (2015) feature.
It is supported in all modern browsers:
Chrome | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes |
event.deltaX
is not supported in Internet Explorer 11 (or earlier).
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!