natas
natas

Reputation: 179

How to make an item "draggable" using html?

Is there a way to just use html to make an item draggable? (not just classifying an element as draggable)

Upvotes: 2

Views: 1534

Answers (5)

Jon Winstanley
Jon Winstanley

Reputation: 23311

Draggable Enlightenment


Unfortunately, HTML is a feeble presentational language which merely gives us the functionality to describe structure of text-based data in a document. It has no way of adding marvelous interactions such as 'draggability'.

Luckily, JavaScript allowed such interactions and it's widespread uptake in web browsers caused developers to rejoice! However browsers implemented JavaScript in a variety of ways, causing heartache and distress for debuggers and testers.

Alas, help is at hand. JavaScript frameworks have become the solution to the misery of inconsistent implementations and developers can again add interactions to their pages.

Arguably the finest of these frameworks goes by the name of jQuery and can be found here. Others go by the name of Prototype and Dojo.

Get to know one of them closely and draggable enlightenment will be yours.

Upvotes: 2

Rich Bradshaw
Rich Bradshaw

Reputation: 72975

If you are happy using HTML5, then there is support for draggable elements, but it does still use javascript.

HTML5 adds a couple of extra events: ondragenter, ondrop and ondragover.

Here's an example page: http://ljouanneau.com/lab/html5/demodragdrop.html

Upvotes: 2

James
James

Reputation: 82096

Nope Javascript. Have a look at JQuery.

Upvotes: 3

Kirschstein
Kirschstein

Reputation: 14868

No, you'll need to use javascript.

jQuery is very popular javascript framework which does a lot of the heavy lifting for you. Here are the docs for their draggable component.

Upvotes: 7

Alan Haggai Alavi
Alan Haggai Alavi

Reputation: 74222

You will need to use Javascript for that.

Upvotes: 0

Related Questions