trim the length of url text

trim the length of url text

I have a table that contains links and i want to reduce the visible text for a url if it is over 35 chars.

I have managed to do this. However, my script is replacing the link as a string, so users can't click on a link because of my script.

I want to keep the url but change the text displayed, how do i keep it all together?

here is my fiddle