Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access the `draggable` attribute with javascript

Tags:

People also ask

How do I use draggable JS?

By default, only image and text can be draggable. To drag an image, you simply hold the mouse button down and then move it. To drag the text, you need to highlight some text and drag it in the same way as you would drag an image.

What values can you use for the draggable attribute?

The draggable attribute can have the following values: true: the element can be draggable. false: the element cannot be draggable. auto: drag is the default browser behavior.

How do I make draggable content?

To make an object draggable set draggable=true on that element. Just about anything can be drag-enabled: images, files, links, files, or any markup on your page.

Which HTML attribute is used to determine if an element is draggable?

The draggable global attribute is an enumerated attribute that indicates whether the element can be dragged, either with native browser behavior or the HTML Drag and Drop API.


So the question is : How can you do that ? I want to change the draggable attribute to "false" so the element that was previously draggable will lose this property.

I will give you a div so you will have something to start with :

     <div id="div1"  draggable="true" ondragstart="drag(event) "onDblClick="edit('div1')">
     </div>