GlobalEventHandlers.onmouseout

  • Revision slug: DOM/element.onmouseout
  • Revision title: element.onmouseout
  • Revision id: 17758
  • Created:
  • Creator: ziyunfei
  • Is current revision? No
  • Comment 16 words added, 2 words removed

Revision Content

{{ DomRef() }}

Summary

The onmouseout property returns the onMouseOut event handler code on the current element.

Syntax

element.onMouseOut = event handling code

Example

<!doctype html>  
<html>  
<head>  
<title>onmouseover/onmouseout event example</title>  
<script type="text/javascript">  
    function initElement()  
    {  
        var p = document.getElementById("foo");  

        p.onmouseover = showMouseOver;
        p.onmouseout = showMouseOut;
    };  

    function showMouseOver()  
    {  
        var notice = document.getElementById("notice");
        notice.innerHTML = 'mouse over detected';
    }
    
    function showMouseOut()
    {
        var notice = document.getElementById("notice");
        notice.innerHTML = 'mouse out detected';
    }


</script>  
<style type="text/css">  
    #foo {  
    border: solid blue 2px;  
    }  
</style>  
</head>  
<body onload="initElement()";>  
    <span id="foo">My Event Element</span>
    <p>mouve your mouse over and out the above element.</p>  
    <div id="notice"></div>
</body>  
</html>  

Edit section

Notes

The mouseout event is raised when the mouse leaves an element (e.g, when the mouse moves off of an image in the web page, the mouseout event is raised for that image element).

Specification

DOM Level 0. Not part of specification.

{{ languages( {"fr": "fr/DOM/element.onmouseout","zh-cn": "zh-cn/DOM/element.onmouseout" } ) }}

Revision Source

<p>{{ DomRef() }}</p>
<h3 id="Summary">Summary</h3>
<p>The <strong>onmouseout</strong> property returns the onMouseOut event handler code on the current element.</p>
<h3 id="Syntax">Syntax</h3>
<pre class="eval">element.onMouseOut = <em>event handling code</em>
</pre>
<h3 class="editable" id="Example"><span><span>Example</span></span></h3>
<pre class="brush: html">&lt;!doctype html&gt;  
&lt;html&gt;  
&lt;head&gt;  
&lt;title&gt;onmouseover/onmouseout event example&lt;/title&gt;  
&lt;script type="text/javascript"&gt;  
    function initElement()  
    {  
        var p = document.getElementById("foo");  

        p.onmouseover = showMouseOver;
        p.onmouseout = showMouseOut;
    };  

    function showMouseOver()  
    {  
        var notice = document.getElementById("notice");
        notice.innerHTML = 'mouse over detected';
    }
    
    function showMouseOut()
    {
        var notice = document.getElementById("notice");
        notice.innerHTML = 'mouse out detected';
    }


&lt;/script&gt;  
&lt;style type="text/css"&gt;  
    #foo {  
    border: solid blue 2px;  
    }  
&lt;/style&gt;  
&lt;/head&gt;  
&lt;body onload="initElement()";&gt;  
    &lt;span id="foo"&gt;My Event Element&lt;/span&gt;
    &lt;p&gt;mouve your mouse over and out the above element.&lt;/p&gt;  
    &lt;div id="notice"&gt;&lt;/div&gt;
&lt;/body&gt;  
&lt;/html&gt;  
</pre>
<div class="editIcon" style="visibility: hidden;"> <h3 class="editable" id="sect1"><a href="/en/DOM/element.onmouseover#section_3?action=edit&amp;sectionId=3#section_3" title="Edit section"><span class="icon"><img alt="Edit section" class="sectionedit" src="/skins/common/icons/icon-trans.gif"></span></a></h3>
</div>
<h3 id="Notes">Notes</h3>
<p>The mouseout event is raised when the mouse leaves an element (e.g, when the mouse moves off of an image in the web page, the mouseout event is raised for that image element).</p>
<h3 id="Specification">Specification</h3>
<p>DOM Level 0. Not part of specification.</p>
<p>{{ languages( {"fr": "fr/DOM/element.onmouseout","zh-cn": "zh-cn/DOM/element.onmouseout" } ) }}</p>
Revert to this revision