javascript - Break the string into two lines -
i want break string 2 lines, line should not break two, @ half of word. how can this?
the string format this:
var words="value.eight.seven.six.five.four.three"
expected output is:
"value.eight.seven. six.five.four.three"
try this:
var words="value.eight.seven.six.five.four.three" var wordsarr = words.split("."); var line1 = wordsarr.slice(0,math.floor(wordsarr.length/2)).join("."); var line2 = wordsarr.slice(math.floor(wordsarr.length/2)).join(".");
here working fiddle:
Comments
Post a Comment