Open In App

HTML | DOM Style cursor Property

The cursor property is used in HTML DOM to set or return the type of cursor to display for the mouse pointer

Syntax:



object.style.cursor
object.style.cursor=value

Property Values:

Return Values: It returns a String, value which representing the displayed mouse cursor when the mouse pointer is over an element



Example: 




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML | DOM Style cursor Property
    </title>
    <style>
        .wait {
            cursor: wait;
        }
         
        h1 {
            color: green;
        }
    </style>
</head>
 
<body>
    <center>
 
        <h1>GeeksforGeeks</h1>
        <p id="myP">
          Mouse over this text before and
          after you have clicked the button below!
        </p>
 
        <button type="button"
                onclick="myFunction()">
          Change cursor
        </button>
 
        <script>
            function myFunction() {
                document.getElementById(
                  "myP").style.cursor = "pointer";
            }
        </script>
    </center>
</body>
 
</html>

Output:

  

Supported Browsers: The browser supported by HTML | DOM Style cursor Property are listed below:


Article Tags :