Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript max length with elipsis

function truncate_with_ellipsis(s,maxLength) {
   if (s.length > maxLength) {
      return s.substring(0, maxLength) + '...';
   }
   return s;
};
alert(truncate_with_ellipsis("hello how are you today?",9));//hello how...
 
PREVIOUS NEXT
Tagged: #javascript #max #length #elipsis
ADD COMMENT
Topic
Name
1+7 =