jqueryHow do I use jQuery to make an element draggable?
Using jQuery to make an element draggable is fairly straightforward. The following example code will create a draggable
element:
<div id="myDiv">Drag me!</div>
<script>
$( "#myDiv" ).draggable();
</script>
This code will make the
element with the id of "myDiv" draggable.
The code is broken down as follows:
- The HTML element to be made draggable, in this case a element with the id of "myDiv".
- The jQuery draggable() method, which will make the element draggable.
For more information, see the jQuery UI draggable documentation.
More of Jquery
- How do I use jQuery ZTree to create a hierarchical tree structure?
- How do I use jQuery to zip files?
- How do I download a zip file using jQuery?
- How do I use jQuery to detect window resize events?
- How can I use jQuery in WordPress?
- How do I use jQuery to change the z-index of an element?
- How can I use JQuery with Yii2?
- How can I use jQuery to find an element on a webpage?
- How do I change the background color using jQuery?
- How do I use jQuery to zoom in or out on an element?
See more codes...