Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to set draggable ="true" through Javascript ?

1,723 views
Skip to first unread message

til@k

unread,
Jul 11, 2012, 3:07:44 AM7/11/12
to
hii ,

I am creating a div dynamically through javascript . so i need to set property through only. Can anybody tell how to set the draggable ="true" for a div through javascript. I tried with this not working properly.
(htmlElement.draggable = true;)

Plz help
Thanks in Advance

camilleriluke

unread,
Jul 11, 2012, 4:36:51 AM7/11/12
to
var div = document.createElement('div');
div.draggable = true;

// the value of the div variable should be: <div draggable="true"></div>


On Wednesday, July 11, 2012 9:07:44 AM UTC+2, til@k wrote:
> hii ,
>
> I am creating a div dynamically through javascript . so i need to set property through only. Can anybody tell how to set the draggable =&quot;true&quot; for a div through javascript. I tried with this not working properly.

Jukka K. Korpela

unread,
Jul 11, 2012, 7:06:37 AM7/11/12
to
2012-07-11 11:36, camilleriluke wrote:

> var div = document.createElement('div');
> div.draggable = true;

That would technically set the attribute, but dragging and dropping is
more complicated, with browser-dependent oddities; see

http://www.htmlgoodies.com/html5/tutorials/html-5-drag-drop-basics.html
https://developer.mozilla.org/En/DragDrop/Drag_Operations

--
Yucca, http://www.cs.tut.fi/~jkorpela/


Fidelis Mundia

unread,
Jul 6, 2022, 5:42:22 AM7/6/22
to
const div = document.createElement("div")
div.setAttribute("draggable", true)

Härra Rabmo

unread,
Jul 6, 2022, 12:12:57 PM7/6/22
to
Hey guy. Would You want to get rich with me doing programming? If yes, call me !!!!!!!!!

✆☎☏📱📞 : 372 53900660
0 new messages