<!DOCTYPE html>
<
html
lang
=
"en"
>
<
head
>
<
meta
charset
=
"utf-8"
>
<
link
href
=
rel
=
"stylesheet"
>
<
script
src
=
</
script
>
<
script
src
=
</
script
>
<
style
>
.drag
{
width: 90px; height: 50px;
border: 1px solid black;
background-color:blue;
}
.drop2, .drop3 {
width: 200px; height: 50px;
border: 1px solid black;
float : center;
background-color:green;
}
</
style
>
<
script
>
$(function() {
$("#btn").on('click', function () {
var widget = $(".drop2").droppable( "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!" );
}
});
$( ".drop3" ).droppable("disable");
$( ".drop3" ).droppable({
drop: function( event, ui ) {
$( this ).find( "p" ).html( "Dropped!" );
}
});
});
</
script
>
</
head
>
<
body
>
<
center
>
<
h1
style
=
"color:green;"
>GeeksforGeeks</
h1
>
<
h3
>jQuery UI Droppable widget() method</
h3
>
<
div
class
=
"drag"
>
<
p
>Drag</
p
>
</
div
>
<
br
>
<
div
class
=
"drop2"
>
<
p
>Drop here</
p
>
</
div
>
<
br
>
<
div
class
=
"drop3"
>
<
p
>Disable - Can't Drop Here</
p
>
</
div
>
<
br
>
<
input
type
=
"button"
id
=
"btn"
value
=
"Widget"
>
<
h4
><
span
id
=
"spanID"
></
span
></
h4
>
</
center
>
</
body
>
</
html
>