Thanks for your code.
I have modified it a bit to make it work in some special cases.
Posting the modified code below -
Code:
function wordwrap(str, len) {
len = len || 10;
/* Regex to remove spaces before the start of any html tag */
str = str.replace(/ +</g,'<');
/* Regex to insert <wbr/> after every html tag or a text of 'len' characters
Leave a comment: