【问题标题】:How to disable drag and drop of text within the textarea?如何禁用文本区域内的文本拖放?
【发布时间】:2012-12-03 11:36:22
【问题描述】:

我正在从事 UI 设计,我需要使用 Html textarea 对象。示例代码为:

<textarea rows="5" cols="60" spellcheck="false" style="font-size:12px; font-family: Verdana;">
Abc
Xyz
Mnp
Pqr
</textarea>

我不想禁用 textarea,因为存在一些跨浏览器问题。如果我指向'xyz'中的'y'并将其拖动到文本'Mnp'之后,它将被移动为'Mnpyz'。我想避免文本区域内文本的这种拖放功能。

【问题讨论】:

    标签: html user-interface drag-and-drop textarea


    【解决方案1】:

    如果不希望用户改变textarea的内容,可以使用readonly属性。

    <textarea rows="5" cols="60" spellcheck="false" style="font-size:12px; font-family: Verdana;"
        readonly="readonly">
    Abc
    Xyz
    Mnp
    Pqr
    </textarea>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-12-08
      • 2019-08-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-24
      • 2018-07-15
      相关资源
      最近更新 更多