Open In App

jQuery UI Datepicker destroy() Method

Improve
Improve
Like Article
Like
Save
Share
Report

jQuery UI consists of GUI widgets, visual effects, and themes implemented using HTML, CSS and jQuery. jQuery UI is great for building UI interfaces for the webpages. jQueryUI Datepickers widget allow users to enter dates easily and visually. 

In this article, we will use jQuery UI Datepicker destroy() method to remove the datepicker functionality completely from the widget. This method does not accept any parameter and returns the element back to its pre-init state.

Syntax:

$(".selector").datepicker("destroy");

CDN Link: First, add jQuery UI scripts needed for your project.

<link href = “https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css” rel = “stylesheet”>
<script src = “https://code.jquery.com/jquery-1.10.2.js”></script>
<script src = “https://code.jquery.com/ui/1.10.4/jquery-ui.js”></script>

Example: This example describes the uses of jQuery UI Datepicker destroy() Method.

HTML




<!doctype html>
<html lang="en">
  
<head>
    <meta charset="utf-8">
    <link href=
    rel="stylesheet">
    <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
    </script>
  
    <!-- jQuery code -->
    <script>
        $(function () {
            $("#GFG").datepicker();
  
            $("#btn").on('click', function () {
                $("#GFG").datepicker("destroy");
            });
        });
    </script>
</head>
  
<body>
    <center>
        <h1 style="color: green;">
            GeeksforGeeks
        </h1>
          
        <h3>jQuery UI Datepicker destroy() Method</h3>
  
        <p>Enter Date: <input type="text" id="GFG"></p>
  
        <input type="button" id="btn" 
            style="padding: 5px 15px;" 
            value="Destroy the Widget">
    </center>
</body>
  
</html>


Output:

Reference: https://api.jqueryui.com/datepicker/#method-destroy



Last Updated : 21 Dec, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads