MDN self-hosted library · e01.org

HTMLElement: draggable property

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

js
const draggableElement = document.querySelector(".draggable-element");
const notDraggableElement = document.querySelector(".not-draggable-element");

// enable the target element's ability to drag
draggableElement.draggable = true;

// disable the target element's ability to drag
notDraggableElement.draggable = false;