html - jQuery add a to text after 50 characters -


I use the tag "html" on the tag "
> After adding HTML to more than 50 characters

My HTML:

  & lt; Table & gt; & Lt; TR & gt; & Lt; Td class = "ccol1" & gt; If it is 50 characters in its characters then it should go to the next line & lt; / Td> & Lt; / TR & gt; & Lt; / Table & gt;   


I tried to use Google's results but it does not seem to work.

  $ ('.ccol1') .each (function () {var str = $ ('td' + '.ccol1'); var htmlfoo = str.match (/. {1 , 50} / g) .join ("& lt; br / & gt;"); $ (this) .html (str);});   

Besides, I only want to do this using jQuery, please do not use CSS word-wrap.

Thanks

Here is a JSFiddle link based on your existing code.

As the code snippet

  $ ('ccol1'). Each (function () {var str = $ (this) .html (); var htmlfoo = str.match (/. {1,50} / g) .joint ("& lt; br / & gt;"); $ (This) .html (htmlfoo);});   

Note that var str = $ (this) .html (); which refers to the element in every ,

Comments

Popular posts from this blog

c# - Textbox not clickable but editable -

Matlab transpose a table vector -

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -