Open In App

jQuery UI Spinner instance() Method

Last Updated : 24 May, 2022
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. jQuery UI spinner widget helps us to increment and decrement values of an input element using up and down arrows. 

In this article, we will see how to use the instance() method in the jQuery UI spinner. This method returns the spinner’s instance object. If the spinner element does not have an associate element, then it returns undefined.

Syntax:

$( ".selector" ).spinner( "instance" );

Parameters: This method does not accept any parameters.

Return Value: This method returns the spinner instance object.

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

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

Example: This example describes the jQuery UI Spinner instance() method.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="utf-8" />
    <title>  jQuery UI Spinner instance() Method   </title>
      
    <link rel="stylesheet" href=
"//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">
  
    <script src=
"//code.jquery.com/jquery-1.12.4.js"></script>
    <script src=
 "//code.jquery.com/ui/1.12.1/jquery-ui.js">
    </script>
  
    <style>
        h1 {
            color: green;
        }
  
        #divID {
            width: 600px;
        }
    </style>
</head>
  
<body>
    <center>
        <h1>GeeksforGeeks</h1>
  
        <h2>jQuery UI Spinner instance() Method</h2>
  
        <input id="divID">
        <br><br>
  
        <input type="button" id="btn" 
               value="Spinner Instance Value" 
               style="padding: 5px 15px;">
    </center>
  
    <script>
        $(function () {
            $("#divID").spinner();
  
            $("#btn").on('click', function() {
                console.log($("#divID").spinner("instance"));
            });
        });
    </script>
</body>
</html>


Output:

 

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



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

Similar Reads