Skip to content
Related Articles

Related Articles

jQuery UI Draggable widget() Method

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 20 Jan, 2022

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 Draggable widget() method to return a jQuery object containing the Draggable element. It does not accept any parameter for functioning.


var widget = $( ".selector" ).draggable( "widget" );

Parameter: This method does not accept any parameter.

Return type: This method returns an object value that contains the draggable element.

CDN Link: Add these jQuery Mobile scripts which will be needed for your project.

<link href = “” rel = “stylesheet”>
<script src = “”></script>
<script src = “”></script>

Example: This example demonstrates the jQuery UI Draggable widget() method.


<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8">
    <link href=
    <script src=
    <script src=
            width: 90px; height: 50px;
            border: 1px solid black;
            width: 200px; height: 50px;
            border: 1px solid black;
            float : center;
        $(function() {
            $("#btn").on('click', function () {
                var widget = $(".drag").draggable( "widget" );
                document.getElementById('spanID').innerHTML += 
                    "No of jQuery object : " 
                     + Object.keys(widget).length;
            $( ".drag" ).draggable();
            $( ".drop2" ).droppable({
            drop: function( event, ui ) {
                $( this ).find( "p" ).html( "Dropped!" );
        <h1 style="color:green;">GeeksforGeeks</h1>
        <h3>jQuery UI Draggable widget() method</h3>
        <div class="drag">
        <div class="drop2">
            <p>Drop here</p>
        <input type="button" id="btn" value="Widget">
        <h4><span id="spanID"></span></h4>


jQuery UI Draggable widget() Method

jQuery UI Draggable widget() Method


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!