我想做个鼠标移动到div时弹出个提示框来

解决方案 »

  1.   

    <html>
    <head>
    <script language="javascript">function a()
    {
    window.alert('aaa')
    }
    </script>
    </head>
    <body>
    <div id="lpdiv" onmouseover="a();">888888888</div>
    </body>
    </html>
    </script>
      

  2.   

    <html>
    <head>
    <script language="javascript">
    window.onload=function(){
     var nam=document.getElementById("lpdiv")
     nam.onmouseover=window.a;
    };
    function a()
    {
    window.alert('aaa');
    };
    </script>
    </head>
    <body>
    <div id="lpdiv">here</div>
    </body>
    </html>
      

  3.   

    谢谢了 可是我想把JS的代码都写在JS文件里 所以用这个document.getElementById("lpdiv")可是为什么不行