+ 2

Why is my code not working. I want to make a draggable div element using jQuery. I have linked all the required jQuery file.

https://code.sololearn.com/W78XWCIJUlpm/?ref=app

2nd May 2021, 8:18 AM
mustafa raza
mustafa raza - avatar
2 Respuestas
+ 2
On Desktop your code works perfectly fine. You can drag the div using mouse. So I assume your problem is that it does not work for touch devices to drag the div. It seems that jQuery does not fully support touch events. By adding some js code to replace the touch events by mouse events which I found here: https://stackoverflow.com/questions/1517924/javascript-mapping-touch-events-to-mouse-events it is possible to achieve a touch draggable div element: Note though that this is a bit hacky and won't necessarily work under all circumstances. https://code.sololearn.com/W4A209A2255a/?ref=app
2nd May 2021, 10:34 AM
Hape
Hape - avatar
+ 1
Hape thank you , yes it was working on desktop .
2nd May 2021, 10:39 AM
mustafa raza
mustafa raza - avatar