如何从 onmouseover 事件调用 JavaScript 函数?


当你将鼠标移动到任何元素上时,onmouseover 事件将触发。

示例

你可以尝试运行以下示例来学习如何从 onmouseover 事件调用 JavaScript 函数

Live Demo

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

更新于: 08-01-2020

2K+ 浏览量

开启你的 职业生涯

完成课程,获得认证

开始
广告
© . All rights reserved.