Today in this tutorial we are going to learn how to make a div element draggable so that we can move it anywhere just by dragging using jQuery UI.
Here I am going to show you a simple example. In this example, we will use jQuery and a jQuery plugin that called jQuery UI. jQuery UI is so much popular these days that lots of popular websites are also using it.
In the above piece of jQuery code, we have applied the draggable method to the div element with div ID "draggable". As you can see that, it is only three lines of code. But soon, you will see that these few lines of code are so powerful.
You can see that we have set the cursor property move which you see on any website where draggable content uses.
Save the above code as an HTML file and give it any name that you prefer. After that, open it with your browser and you will see a div element with the text "Drag me anywhere". You can drag it anywhere on the browser screen.
I hope you liked this tutorial and you have understood. If there is any problem to understand then let me know. I would like to help you.
« How to unzip or extract zip files in PHP?