How to make div accessible and draggable
<div contenteditable="true" id="d"> <span>Text to edit</span> </div> $("#d").draggable(); I can only drag this div, but how can I edit it (for example, when editing a property, doubleclick becomes active, and when you drag a click, it is activated)?
+9
gaurav Apr 25 '12 at 13:50 2012-04-25 13:50
source share4 answers
$("#d").draggable() .click(function() { $(this).draggable({ disabled: false }); }).dblclick(function() { $(this).draggable({ disabled: true }); }); +17
ocanal Apr 25 2018-12-12T00: 00Z
source share $("#d") .draggable() .click(function(){ if ( $(this).is('.ui-draggable-dragging') ) { return; } $(this).draggable( "option", "disabled", true ); $(this).attr('contenteditable','true'); }) .blur(function(){ $(this).draggable( 'option', 'disabled', false); $(this).attr('contenteditable','false'); }); This is a DEMO: http://jsfiddle.net/UH9UE/222/ .
+8
ETY001 Feb 19 '13 at 7:42 2013-02-19 07:42
source shareAnother option is to pass .draggable ({handle: "handleDiv"}), which allows you to constantly drag and drop and allow editing of content. Just make your draggable div with two divs inside: the handle and your contenteditable div.
+5
Richard Jan 31 '13 at 16:25 2013-01-31 16:25
source share <div contenteditable="true" id="d"> <span>Text to edit</span> </div> $(function(){ $("#d").click(function() { $("#d").draggable(); }); $("#d").dblclick(function(){ see here for this functionality http://stackoverflow.com/questions/2441565/how-do-i-make-a-div-element-editable-like-a-textarea-when-i-click-it }); }); 0
Nolan Knill Apr 25 2018-12-12T00: 00Z
source share