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);
}
}
}
Sameera at LinkedIn
