jQuery UI Draggable create Event
Last Updated :
29 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.
The jQuery UI Draggable create Event is used to trigger when the draggable is created.
Syntax:
We need to initialize the Draggable widget with the create a callback function:
$( ".selector" ).draggable({
create : function( event, ui ) {}
});
Bind an event listener to the dragcreate an event:
$( ".selector" ).on( "dragcreate", function( event, ui ) {} );
Parameters: These are the following parameters that are accepted. Â
- event: This event is triggered when the sort creates an item.
- ui: This parameter is of type object with below-given options.
- helper: This parameter is the jQuery object representing the sorted helper.
- item: This parameter is the jQuery object that represents the current dragged item.
- offset: This parameter is the current absolute position of the helper object which is represented as { top, left }.
- position: This parameter is the current position of the helper object which is represented as { top, left }.
CDN Link: The following jQuery Mobile scripts will be needed for your project so we need to add these scripts to 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 the jQuery UI Draggable create Event.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet"
href=
"https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css">
<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>
<style>
.dragg {
width: 100px;
height: 50px;
border: 1px solid black;
background-color: blue;
}
.dropp2{
width: 250px;
height: 50px;
border: 1px solid black;
float: center;
background-color: green;
}
#btn
{
padding: 0.5;
font-size: 20px;
height: 40px;
width: 40%;
}
</style>
<script>
$(function () {
$(".dragg").draggable({
create : function (event, ui) {
$("#gfg").html(
"<b>Draggable Widget has been created.</b><br>");
}
});
$(".dropp2").droppable({
drop: function (event, ui) {
$(this)
.find("p")
.html("Dropped!");
}
});
});
</script>
</head>
<body>
<center>
<h1 style="color:green;">GeeksforGeeks</h1>
<h3>jQuery UI Draggable create Event</h3>
<div class="dragg">
<p>Drag</p>
</div>
<br>
<div class="dropp2">
<p>Drop here</p>
</div>
<br>
<h3><span id="gfg"></span></h3>
</center>
</body>
</html>
Output:
jQuery UI Draggable create EventReference: https://api.jqueryui.com/draggable/#event-create
Similar Reads
jQuery UI Droppable create Event jQuery UI is a web-based technology and consists of various GUI widgets, visual effects, and themes. These features can be 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 appl
2 min read
jQuery UI Droppable activate Event jQuery UI is a web-based technology and consists of various GUI widgets, visual effects, and themes. These features can be 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 appl
2 min read
jQuery UI Draggable drag Event jQuery UI is a web-based technology and consists of various GUI widgets, visual effects, and themes. These features can be 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 appl
2 min read
jQuery UI Draggable stop Event In this article, we are going to learn that how we can use the jQuery UI Draggable stop event. Draggable will be used to drag the HTML element throughout the webpage. jQuery UI Draggable consists of options, methods, and events. The stop is one example of a Draggable event. Now let's understand what
3 min read
jQuery UI Draggable start Event jQuery UI consists of GUI widgets, visual effects, and themes implemented using jQuery, CSS, and HTML. jQuery UI is great for building UI interfaces for the webpages. In this article, we are going to understand the jQuery UI Draggable start event. We can drag any HTML element throughout the page. Sy
2 min read