Open In App

HTML DOM Input Datetime select() Method

Improve
Improve
Like Article
Like
Save
Share
Report

The input Datetime select() method in HTML DOM is used in selecting the content of the Datetime Text field.

Syntax:

Datetimebject.select()

Parameters: It does not accept any parameter.

Example: This example uses the input Datetime select() method to select the Datetime field.

HTML




<!DOCTYPE html>
<html>
 
<head>
    <style>
        h1 {
            color: green;
        }
 
        body {
            text-align: center;
        }
    </style>
</head>
 
<body>
    <h1>GeeksforGeeks</h1>
    <h2>HTML DOMInput Datetime select() method</h2>
    <br>
 
    <input type="datetime" id="Test_Datetime"
        value="2019-02-18T12:00Z">
    <p>
        To select the value of the datetime
        field, double click the "Select
        Datetime Field" button.
    </p>
    <button ondblclick="My_Datetime()">
        Select Datetime Field
    </button>
 
    <script>
        function My_Datetime() {
            document.getElementById("Test_Datetime").select();
        }
    </script>
</body>
 
</html>


Output:

Supported Browsers:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Safari
  • Opera


Last Updated : 14 Sep, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads