JS 鼠标事件onmouseover:鼠标移到某元素之上;onmouseout:鼠标从某元素移开


<html>
    <head>
        <meta charset="UTF-8">
        <title>title>
        <script type="text/javascript">
            window.onload=function(){
                var img=document.getElementsByTagName("img")[0];
                img.onmouseover=function(){
                    document.getElementById("msg").innerHTML="over...";
                }
                img.onmouseout=function(){
                    document.getElementById("msg").innerHTML="out...";
                }
            }
        script>
    head>
    <body>
        <img src="image/ad-03.jpg" />
        <div id="msg">div>
    body>
html>

JS 鼠标事件onmouseover:鼠标移到某元素之上;onmouseout:鼠标从某元素移开_第1张图片

你可能感兴趣的:(JS-事件-鼠标事件)