Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> JavaScript

Sự kiện onmousemove trong JavaScript là gì?

Kích hoạt liên tục khi con trỏ chuột di chuyển bên trong element.

Ví dụ

<html>
  <head>
    <script>
      function sayHello() { alert("Mouse Move"); }
    </script>
  </head>
  <body>
    <p onmousemove="sayHello()">Di chuyển chuột ở đây</p>
  </body>
</html>

Lưu ý: Sự kiện này fire rất nhiều lần, tránh gán xử lý nặng hoặc alert (sẽ spam).