javascript - Clean Html from contenteditable -
i'm trying save contenteditable data javascript-array. every new line should array-item
first of cleaned out chromes html:
html = html //empty line looks this: .replace(/<div><br\s*[\/]?><\/div>/gi,'') //chrome wraps each line in div .replace(/<div>/gi,'\n') .replace(/<\/div>/gi,'') //sometimes chrome adds break. .replace(/<br\s*[\/]?>/gi,'');
later on do:
html.split("\n");
i tested in firefox, , realized make newlines adding breaks. haven't looked @ internet explorer yet.
is there more general-approach or well-tested way extract text lines of text separated newline-carachter html?
try this:
html
<div id="container" contenteditable=true></div>
javascript
var container = document.getelementbyid('container'); container.onblur = function () { console.log(this.innertext.split('\n')); }
jsfiddle: http://jsfiddle.net/ezlhf/
Comments
Post a Comment