微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javascript – Backspace删除整个span元素

是否可以使用退格键防止跨度删除

<div class="form-control" contenteditable="true">
  <span class="correct-answer">
    <span contenteditable="false">The correct answer is (A) 1 to 2. </span>
    <span class="sentence" num="11">dgsdgsg. sgsdgs sgsgs.</span>
  </span>
</div>

示例:http://jsfiddle.net/pvj64px9/1/

The correct answer is (B) 2 to 3. and `Choice A (1 to 2) is incorrect. ` must not be deleted.

解决方法:

更新您的父容器以使contenteditable =“false”

<div id="window-kitkat" class="form-control" contenteditable="false">

并将您想要的可编辑元素设置为true,例如,

<span class="sentence" num="10" contenteditable="true">jfbgfdgdf sgdsgsd.</span>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐