如何避免文本在contenteditable内拖放 JQuery

问题描述 投票:0回答:1

我需要避免在内容可编辑<p>中拖放文本。我的示例HTML代码如下,我的内容可编辑<p>具有单独的<span>如下。

<div class="row">
  <p id="" class="given" contenteditable="true"><span>Lorem</span> <span>trst</span> <span>Lorem</span> <span>Lorem</span> <span>Lorem</span> <span>Lorem</span> </p>
</div>

您可以在此图像中看到,我可以选择文本并将其拖放到另一个位置,我需要避免该可拖动选项。 enter image description here

我看到了关于此的几篇文章,

Disable drag and drop of selected text

How can I prevent text/element selection with cursor drag

我需要使用jQuery。我该怎么办

javascript jquery html contenteditable paragraph
1个回答
0
投票

尝试一下,使用dragstart。当用户开始拖动元素或文本选择时,将触发dragstart事件。

© www.soinside.com 2019 - 2024. All rights reserved.