如何在 onmouseover 事件中调用 JavaScript 函数?


onmouseover 事件触发器在将鼠标移至任何元素时启动。

示例

尝试运行以下示例以了解如何从 onmouseover 事件中调用 JavaScript 函数

在线演示

<html>
   <head>
      <script>
         <!--
            function over() {
               document.write ("Mouse Over");
            }
            function out() {
               document.write ("Mouse Out");
            }
         //-->
      </script>
   </head>
   <body>
      <p>Bring your mouse inside the division to see the result:</p>
      <div onmouseover="over()" onmouseout="out()">
         <h2> This is inside the division </h2>
      </div>
   </body>
</html>

更新于: 2020 年 1 月 8 日

2 千人次浏览

开启您的 职业生涯

完成课程并获得认证

开始
广告
© . All rights reserved.