Relax Breath of Solution.Community tech blog of Sameera Thilakasiri - Consultant UI, UX, RWD Specialist/ Interactive Designer

Just I wanted.. Do you?…

String Truncation (Ellipsis) using jQuery for IE FF Opera

Posted on July 19, 2011 | Comments Off on String Truncation (Ellipsis) using jQuery for IE FF Opera

you could achieve the same thing by writing a small JavaScript code:

$(document).ready(function() {
   $(.fixWidth).each(function()   {
      var limit = 50;
      var ellipsis = "...";
      if( $('#limitedWidthTextBox').val().length()   > limit)
      {
         var trimmedText = $('#limitedWidthTextBox').val().substring(0, limit-4); // -4 to include the ellipsis size and also since it is an index
           trimmedText   += elipsis;
         $('#limitedWidthTextBox').val(trimmedText);
      }
   }
}

Author
Sameera Thilakasiri By Sameera Thilakasiri
,is a front-end developer based in Colombo, is a blogger and a lifestyle photographer.
Follow him Twitter and Google+. Check out him.

Comments

Comments are closed.