JS鼠标单击和双击,可以从事件参数的detail属性加以区分。
| 单击 | 双击中的第1次 | 双击中的第2次 |
| altKey: false | altKey: false | altKey: false |
| bubbles: true | bubbles: true | bubbles: true |
| button: 0 | button: 0 | button: 0 |
| buttons: 1 | buttons: 1 | buttons: 1 |
| cancelBubble: false | cancelBubble: false | cancelBubble: false |
| cancelable: true | cancelable: true | cancelable: true |
| clientX: 831 | clientX: 831 | clientX: 831 |
| clientY: 104 | clientY: 287 | clientY: 287 |
| ctrlKey: false | ctrlKey: false | ctrlKey: false |
| currentTarget: null | currentTarget: null | currentTarget: null |
| defaultPrevented: false | defaultPrevented: false | defaultPrevented: false |
| detail: 1 | detail: 1 | detail: 2 |
| eventPhase: 0 | eventPhase: 0 | eventPhase: 0 |
| fromElement: null | fromElement: null | fromElement: null |
| isTrusted: true | isTrusted: true | isTrusted: true |
| isTrusted: true | isTrusted: true | isTrusted: true |
| layerX: 831 | layerX: 831 | layerX: 831 |
| layerY: 104 | layerY: 287 | layerY: 287 |
| metaKey: false | metaKey: false | metaKey: false |
| movementX: 0 | movementX: 0 | movementX: 0 |
| movementY: 0 | movementY: 0 | movementY: 0 |
| offsetX: 831 | offsetX: 831 | offsetX: 831 |
| offsetY: 104 | offsetY: 287 | offsetY: 287 |
| pageX: 831 | pageX: 831 | pageX: 831 |
| pageY: 104 | pageY: 287 | pageY: 287 |
| path: Array[7] | path: Array[7] | path: Array[7] |
| relatedTarget: null | relatedTarget: null | relatedTarget: null |
| retureValue: true | retureValue: true | retureValue: true |
| returnValue: true | returnValue: true | returnValue: true |
| screenX: 810 | screenX: 810 | screenX: 810 |
| screenY: 179 | screenY: 344 | screenY: 344 |
| shiftKey: false | shiftKey: false | shiftKey: false |
| srcElement: canvas.ol-unselectable | srcElement: canvas.ol-unselectable | srcElement: canvas.ol-unselectable |
| target: canvas.ol-unselectable | target: canvas.ol-unselectable | target: canvas.ol-unselectable |
| timeStamp: 1479972489973 | timeStamp: 1479972491729 | timeStamp: 1479972491900 |
| toElement: canvas.ol-unselectable | toElement: canvas.ol-unselectable | toElement: canvas.ol-unselectable |
| type: "mousedown" | type: "mousedown" | type: "mousedown" |
| view: Window | view: Window | view: Window |
| webkitMovementX: 0 | webkitMovementX: 0 | webkitMovementX: 0 |
| webkitMovementY: 0 | webkitMovementY: 0 | webkitMovementY: 0 |
| which: 1 | which: 1 | which: 1 |
| x: 831 | x: 831 | x: 831 |
| y: 287 | y: 287 |
本文介绍了JavaScript中如何通过鼠标事件的detail属性来区分单击和双击操作。详细展示了单击与双击事件的不同属性值,如detail的变化,帮助开发者更好地理解和实现鼠标事件的监听。
1467

被折叠的 条评论
为什么被折叠?



