Open In App

jQuery UI Resizable instance() Method

Last Updated : 29 Jan, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

jQuery UI  is a web-based technology and consists of GUI widgets, visual effects, and themes implemented using the jQuery, JavaScript Library. jQuery UI is the best tool for building UI interfaces for the webpages. It can also be used to build highly interactive web applications or can be used to add widgets easily.

In this article, we will be using the jQuery UI Resizable instance() method to retrieve the resizable’s instance object. If the element does not have any associated instance, undefined is returned. It does not accept any parameter for functioning.

Syntax:

var Instance = $( ".selector" ).resizable( "instance" );

Parameter: This method does not accept any parameter.

Return type: This method returns an object value that contains the resizable’s instance object.

CDN Link: The following jQuery Mobile scripts will be needed for your project so we need to add these scripts to your project.

<link rel= “stylesheet” href=”https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css”>
<script src= “https://code.jquery.com/jquery-1.12.4.js”></script>
<script src= “https://code.jquery.com/ui/1.12.1/jquery-ui.js”></script>

Example: This example describes the uses of the jQuery UI Resizable instance() Method.

HTML




<!doctype html>
<html lang="en">
  
<head>
    <link rel="stylesheet" 
          href=
    <script src=
    </script>
    <script src=
    </script>
    <style>
        h1 {
            color: green;
        }
  
        .container {
            width: 320px;
        }
  
        #resizable-div {
            width: 150px;
            height: 150px;
            text-align: center;
            border: 2px solid black;
        }
    </style>
    <script>
        $(function () {
            $("#btn").on('click', function () {
                var instances = $("#resizable-div")
                             .resizable("instance");
  
                document.getElementById('GFG').innerHTML
                    += "Instance Value: " +
                    Object.keys(instances).length;
            });
        });
  
        $(function () {
            $("#resizable-div").resizable();
            $("#resizable-div").resizable('enable');
        });
    </script>
</head>
  
<body>
    <center>
        <h1>GeeksforGeeks</h1>
        <h3>jQuery UI Resizable instance() Method</h3>
  
        <div class="container">
            <div id="resizable-div">
                <h3 class="gfg" style = "color:green;">
                  I'm Enable
                </h3>
            </div>
        </div>
        <br>
        <input type="button"
               id="btn"
               style="width: 200px; height: 40px; font-size : 20px;"
               value="Instance">
  
        <h4><span id="GFG"></span></h4>
    </center>
</body>
  
</html>


Output:

jQuery UI Resizable instance() Method

jQuery UI Resizable instance() Method

Reference: https://api.jqueryui.com/resizable/#method-instance



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads