javascript - Moving single-letter word to new line -


is there way move single-letter word next line javascript? code database can't edit manually. i've found function finds these words, have no idea how put these new line.

<div id="flop" class="foobar">lorem ipsum dolor sit amet, consectetur adipisicing      elit, sed eiusmod tempor incididunt ut labore et dolore magna aliqua. ut enim      ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex      commodo consequat. duis aute irure dolor in reprehenderit in volue v      esse cillum dolore eu fugiat nulla p</div><br> <button value="go" onclick="foo();">go</button> 
function foo(){     var d = document.getelementbyid('flop');     var t = d.innerhtml;     var w = t.split(' ');             d.innerhtml = w[0];     var height = d.clientheight;     for(var = 1; < w.length; i++){         d.innerhtml = d.innerhtml + ' ' + w[i];          if(d.clientheight > height){             height = d.clientheight;           if(w[i-1].length === 1){               console.log(w[i-1]);           }         }     } } 

in javascript, \u000a escaped unicode character newline.

if can identify single-letter words, prepend \u000a each word.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -