# Create a Draggable Element in JavaScript

**URL:** <https://forum.kirupa.com/t/create-a-draggable-element-in-javascript/638149>\
**Category:** programming\
**Created:** [April 28, 2018, 5:27am UTC](https://forum.kirupa.com/t/create-a-draggable-element-in-javascript/638149 "2018-04-28T05:27:37Z")\
**Posts on this page:** 4\
**Page:** 8

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [April 20, 2021, 6:26pm UTC](https://forum.kirupa.com/t/create-a-draggable-element-in-javascript/638149/149 "2021-04-20T18:26:36Z")

</div>

These are good suggestions, @Pythonsegmenter! I’ll revise the code as part of a future revision. Welcome to the forums btw 🙂

---

<div class="post-metadata">

**Author:** ![Ux1](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ux1/32/15556_2.png) [@Ux1](https://forum.kirupa.com/u/Ux1)\
**Post date:** [October 3, 2021, 11:32pm UTC](https://forum.kirupa.com/t/create-a-draggable-element-in-javascript/638149/150 "2021-10-03T23:32:01Z")

</div>

@kirupa A newbie to JS, is it feasible to use absolute coordinates (which are relative to the container that contains the `<div>` as far as I understand vs. relative offsets in the script?

---

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [October 4, 2021, 4:23am UTC](https://forum.kirupa.com/t/create-a-draggable-element-in-javascript/638149/151 "2021-10-04T04:23:46Z")

</div>

You should try, but the challenge is that you will need to account for offsets, scrolls, paddings, etc. either way. What you may end up with could look similar to all of the calculations in the script 😃

---

<div class="post-metadata">

**Author:** ![Deepesh\_1](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/deepesh_1/32/17058_2.png) [@Deepesh\_1](https://forum.kirupa.com/u/Deepesh_1)\
**Post date:** [March 12, 2022, 10:41am UTC](https://forum.kirupa.com/t/create-a-draggable-element-in-javascript/638149/152 "2022-03-12T10:41:23Z")

</div>

Hii, how can i drag the same elements multiple times? Please help me with this @kirupa. Its urgent.  
Also, in mobile device the draggable elements are going out of the container.

 ![IMG_20220312_161312](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/d/f/dff5d1de1099d9b83f4bc22c1193cae5901d0386.jpeg)

[Previous page](https://forum.kirupa.com/t/create-a-draggable-element-in-javascript/638149.md?page=7)
