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

来源:6-4 鼠标移开事件(onmouseout)

慕慕8930644

2018-06-28 15:07

<!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>


写回答 关注

3回答

  • 人生白月
    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

JavaScript进阶篇

本课程从如何插入JS代码开始,带您进入网页动态交互世界

468061 学习 · 21891 问题

查看课程

相似问题