退格键删除整个span元素 [英] Backspace deletes whole span element

查看:92
本文介绍了退格键删除整个span元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Is it possible to prevent span deletion with backspace?

<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"

update your parent container to have contenteditable="false"

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

,然后将要编辑的各个元素设置为true,例如

and set the individual elements you want as editable to true, e.g.,

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

这篇关于退格键删除整个span元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆