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>

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...