问答详情
源自:6-4 鼠标移开事件(onmouseout)

请问这样子为什么不能触发鼠标事件?

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>鼠标移开事件 </title>

<script type="text/javascript">

  var name=document.getElementById("first");


  name.onmouseout=function(){

      alert("相信我,frighting");

  }

</script>

</head>

<body>

<form id="first">

  <a href="http://www.imooc.com">点击我</a>

</form>

</body>

</html>


提问者:慕慕8930644 2018-06-28 15:07

个回答

  • 人生白月
    2018-10-25 22:05:03

    <!DOCTYPE HTML>

    <html>

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>鼠标移开事件 </title>

    <script type="text/javascript">

      function message(){

        alert("不要移开,点击后进行慕课网!"); }

    </script>

    </head>

    <body>

    <form>

      <a href="http://www.imooc.com" onmouseout="message()">点击我</a>

    </form>

    </body>

    </html>


  • qq_抛物线_0
    2018-07-04 13:03:06

    <!DOCTYPE HTML>

    <html>

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>鼠标移开事件 </title>

    <script type="text/javascript">

    window.onload = function() {

    var name = document.getElementById("first");

    name.onmouseout = function () {

    alert("相信我,frighting");

    }

    }

    </script>

    </head>

    <body>

    <form id="first">

    <a href="http://www.imooc.com">点击我</a>

    </form>

    </body>

    </html>


  • david_zn315
    2018-06-28 19:48:19

    1111