Home  >  Article  >  Web Front-end  >  How to make DIV editable and draggable sample code_javascript skills

How to make DIV editable and draggable sample code_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:22:101019browse
1. Editable:

Editable

Setting the contentEditable attribute can make the div programmable Editing status

2. Draggable:

$('#move').draggable();
Use jQuery UI's draggable to make the div change into a draggable state, but if both attributes are applied at the same time, the editable function will be disabled.

3. Editable and draggable:
Copy code The code is as follows:

editable

var divTitle=$('#move');
[code ]
divTitle.draggable().click(function ()
{
$(this).draggable({ disabled: false });
$(this).css('backgroundColor', 'transparent');
}).dblclick(function ()
{
$(this).draggable({ disabled: true }) ;
$(this).css('backgroundColor', '#FFFF6F');
});


By controlling this, you can make the div have edit and drag attributes.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn