javascript - Removing empty quotes that only appear in DOM inspector -


in contenteditable div, if text deleted (by user), proceeded space (using spacebar) , text, empty quotes appear below text in dom inspector (chrome , safari, tested).

below what's shown in dom inspector:

<div id="remindertexteditable" contenteditable="true"> " test text" "" </div> 

if text's leading space removed in div, empty quotes still there

<div id="remindertexteditable" contenteditable="true"> "test text" "" </div> 

i tried following code in attempt locate empty quotes using javascript, alerts "1":

var list = document.getelementbyid('remindertexteditable'); var list_items = list.childnodes; alert(list_items.length); 

whatever empty quotes (whitespace?), seem causing layout issues.

how can whatever causing empty quotes removed?

if hit enter while editing, browsers (like firefox) add
tag achieve effect. when hit backspace, cursor appears erase newline, not erase
tag. still there. similar issue can happen other whitespace characters.

mozilla has couple pretty detailed examples have functions delete tab indentations or new lines

https://developer.mozilla.org/en-us/docs/rich-text_editing_in_mozilla.

to have parse innerhtml of contenteditable element. if node has no innerhtml (or text node no nodevalue), delete it. go through br tags , if tag br , has no nextsibling delete it.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -