【发布时间】:2018-09-28 19:39:56
【问题描述】:
我真的试图找到答案,但没有任何答案。我希望能够重新排序句子,即拖放它们。但我也希望它们是可编辑的。哦,是的,最好没有 jquery 之类的......
它会起作用,例如如果需要在编辑和重新排序之间切换,“ctr”键切换内容可编辑。但我无法弄清楚拖动事件如何确定放置它的位置。
<!DOCTYPE html>
<html>
<style>
.sentence1 {color: blue;}
.sentence2 {color: red;}
.sentence3 {color: green;}
</style>
<body>
<div class="paragraph">
<span id="three" class="sentence3" contenteditable="true" >This is really the third sentence.</span>
<span id="one" class="sentence1" contenteditable="true" >This is really the first sentence.</span>
<span id="two" class="sentence2" contenteditable="true" >This is really the second sentence.</span>
</div>
我认为如果解决了这可能对某些人有用,所以我没有提供更多我尝试过但失败的代码。欢迎提出任何建议!
【问题讨论】:
-
我在您的问题中没有看到任何可拖动的代码。你试过什么?
-
首先弄乱 order 属性:developer.mozilla.org/en-US/docs/Web/CSS/order
-
这是一个很好的使用 html、css 和 javascript 的指南:syntaxxx.com/… 不过不确定它如何与 contenteditable 一起工作。
标签: javascript html draggable