Revision: 49586
Updated Code
at July 26, 2011 00:45 by Jamie
Updated Code
function truncate(text, length, truncation) { length = length || 30; truncation = (typeof(truncation) == 'undefined') ? '...' : truncation; return text.length > length ? text.slice(0, length - truncation.length) + truncation : String(text); } truncate("Hello World",10,'...');
Revision: 49585
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 26, 2011 00:41 by Jamie
Initial Code
function truncate(text,length, truncation) { length = length || 30; truncation = (typeof(truncation) == 'undefined') ? '...' : truncation; return text.length > length ? text.slice(0, length - truncation.length) + truncation : String(text); } truncate("Hello World",10,'...');
Initial URL
https://ajax.googleapis.com/ajax/libs/prototype/1.7.0.0/prototype.js
Initial Description
I just ripped it from Prototype for use in my jQuery based code.
Initial Title
Adaptation of Prototype\'s Truncate function
Initial Tags
Initial Language
JavaScript