mouseout
event is fired at an
元素
when a pointing device (usually a mouse) is used to move the cursor so that it is no longer contained within the element or one of its children.
mouseout
is also delivered to an element if the cursor enters a child element, because the child element obscures the visible area of the element.
| 冒泡 | Yes |
|---|---|
| 可取消 | Yes |
| 接口 |
MouseEvent
|
| 事件处理程序特性 |
onmouseout
|
The following examples show the use of the
mouseout
事件。
The following example illustrates the difference between
mouseout
and
mouseleave
events. The
mouseleave
event is added to the
<ul>
to color the list purple whenever the mouse exits the
<ul>
.
mouseout
is added to the list to color the targeted element orange when the mouse exits it.
When you try this out, you'll find that
mouseout
is delivered to the individual list items, while
mouseleave
goes to the overall list, courtesy of the hierarchy of the items and the fact that list items obscure the underlying
<ul>
.
<ul id="test"> <li>item 1</li> <li>item 2</li> <li>item 3</li> </ul>
let test = document.getElementById("test");
// Briefly make the list purple when the mouse moves off the
// <ul> element
test.addEventListener("mouseleave", function( event ) {
// highlight the mouseleave target
event.target.style.color = "purple";
// reset the color after a short delay
setTimeout(function() {
event.target.style.color = "";
}, 1000);
}, false);
// Briefly make an <li> orange when the mouse moves off of it
test.addEventListener("mouseout", function( event ) {
// highlight the mouseout target
event.target.style.color = "orange";
// reset the color after a short delay
setTimeout(function() {
event.target.style.color = "";
}, 500);
}, false);
| 规范 | 状态 |
|---|---|
|
UI Events
The definition of 'mouseout' in that specification. |
工作草案 |
|
DOM (文档对象模型) 3 级事件规范
The definition of 'mouseout' in that specification. |
过时 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
mouseout
event
|
Chrome Yes | Edge 12 | Firefox Yes | IE Yes | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android Yes | Firefox Android Yes | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
完整支持
元素
accessKey
属性
childElementCount
children
classList
className
clientHeight
clientLeft
clientTop
clientWidth
currentStyle
firstElementChild
id
innerHTML
lastElementChild
localName
名称
namespaceURI
nextElementSibling
onfullscreenchange
onfullscreenerror
openOrClosedShadowRoot
outerHTML
part
prefix
previousElementSibling
runtimeStyle
scrollHeight
scrollLeft
scrollLeftMax
scrollTop
scrollTopMax
scrollWidth
shadowRoot
slot
tabStop
tagName
after()
animate()
append()
attachShadow()
before()
closest()
computedStyleMap()
createShadowRoot()
getAnimations()
getAttribute()
getAttributeNames()
getAttributeNode()
getAttributeNodeNS()
getAttributeNS()
getBoundingClientRect()
getClientRects()
getElementsByClassName()
getElementsByTagName()
getElementsByTagNameNS()
hasAttribute()
hasAttributeNS()
hasAttributes()
hasPointerCapture()
insertAdjacentElement()
insertAdjacentHTML()
insertAdjacentText()
matches()
msZoomTo()
prepend()
querySelector()
querySelector()
querySelectorAll()
querySelectorAll()
releasePointerCapture()
remove()
removeAttribute()
removeAttributeNode()
removeAttributeNS()
replaceChildren()
replaceWith()
requestFullscreen()
requestPointerLock()
scroll()
scrollBy()
scrollIntoView()
scrollIntoViewIfNeeded()
scrollTo()
setAttribute()
setAttributeNode()
setAttributeNodeNS()
setAttributeNS()
setCapture()
setPointerCapture()
toggleAttribute()
afterscriptexecute
auxclick
blur
click
compositionend
compositionstart
compositionupdate
contextmenu
copy
cut
dblclick
DOMActivate
DOMMouseScroll
error
focus
focusin
focusout
fullscreenchange
fullscreenerror
gesturechange
gestureend
gesturestart
keydown
keypress
keyup
mousedown
mouseenter
mouseleave
mousemove
mouseout
mouseover
mouseup
mousewheel
MozMousePixelScroll
msContentZoom
MSGestureChange
MSGestureEnd
MSGestureHold
MSGestureStart
MSGestureTap
MSInertiaStart
MSManipulationStateChanged
overflow
paste
scroll
select
show
touchcancel
touchend
touchmove
touchstart
underflow
webkitmouseforcechanged
webkitmouseforcedown
webkitmouseforceup
webkitmouseforcewillbegin
wheel