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 to zip files?
- How do I use jQuery ZTree to create a hierarchical tree structure?
- How can I use JQuery with Yii2?
- How can I get the y position of an element using jQuery?
- How can I make a jQuery XMLHttpRequest?
- How to use jQuery to achieve a specific task?
- How do I create a jQuery widget?
- How do I use jQuery to validate a form?
- How do I download a zip file using jQuery?
- How do I use jQuery to zoom an image when it is clicked?
See more codes...