Skip to content
Related Articles
Open in App
Not now

Related Articles

jQuery event.timeStamp Property

Improve Article
Save Article
Like Article
  • Last Updated : 18 Nov, 2022
Improve Article
Save Article
Like Article

The jQuery event.timeStamp is an inbuilt property which is used to measure difference in milliseconds between the time of event created by the browser and January 1, 1970. 

Syntax:

event.timeStamp

Parameter: It does not accept any parameter because it is a property not a function. 

Example 1: This Example shows the working of event.timeStamp property.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <script src=
    </script>
    <script>
        < !--jQuery code to show the working 
            of event.timeStamp property-- >
            $(document).ready(function () {
                $("p").click(function (event) {
                    $("span").text(event.timeStamp);
                });
            });
    </script>
    <style>
        p {
            width: 80%;
            padding: 20px;
            display: block;
            border: 2px solid green;
        }
    </style>
</head>
  
<body>
    <!-- click on this paragraph -->
    <p>The click event occurred 
        <span style="color:green">unknown</span>
        milliseconds after January 1, 1970.
    </p>
</body>
  
</html>

Output:

 

Example 2: In this example, a pop-up will show how many milliseconds click event occurred after January 1, 1970.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <script src=
    </script>
    <script>
        < !--jQuery code to show the working 
            of event.timeStamp property-- >
        $(document).ready(function () {
            $("div").click(function (event) {
                alert(event.timeStamp + " milliseconds");
            });
        });
    </script>
    <style>
        div {
            width: 40%;
            padding: 20px;
            display: block;
            border: 2px solid green;
            font-size: 2em;
        }
    </style>
</head>
  
<body>
    <center>
        <!-- click inside the box -->
        <div>Geeksforgeeks</div>
    </center>
</body>
  
</html>

Output:

 


My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!