2015-09-17 86 views
4

是否有可能防止用backspace刪除跨度?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. 
+0

當然,但你需要JS來檢查.. –

+0

沒關係,如果它解決了問題! :) –

+0

增加了jsfiddle的例子。 –

回答

1

更新你的父容器有CONTENTEDITABLE = 「假」

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

並設置要爲可編輯的各個元素爲真,例如

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

將測試這一點。 –