Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> JavaScript

วิธีตั้งค่าประเภทของ Cursor (เมาส์) ด้วย JavaScript

ใช้คุณสมบัติ cursor เพื่อเปลี่ยนรูปแบบเคอร์เซอร์เมื่อวางเมาส์เหนือองค์ประกอบ ค่าที่นิยม: pointer, text, wait, help, move, crosshair

ตัวอย่าง

<!DOCTYPE html>
<html>
  <body>
    <h1 id="myID">Heading 1</h1>
    <p>Check the heading before and after mouse hover.</p>
    <button type="button" onclick="display()">Click to change the cursor</button>
    <script>
      function display() {
        document.getElementById("myID").style.cursor = "pointer";
      }
    </script>
  </body>
</html>