Q:

how to customize css ellipse for a text string

Hi I have list of title in a drop-down as string ex: 
"Bharat Untitled offer #564", "Bharat Untitled offer #563" 

respectively.
Its title is long so, We want title should show first eight character, then '...' and last 4 character.
I used css rules:
.title{
    max-width: 100px;
    min-width: 100px;
    overflow: hidden;
    text-overflow:ellipsis;
}

And get output like: 

Bharat Unt...

I want out put like: 

Bharat Untitled...ffer

Any ideas how to do this?

A:

Try this:

var charAtBeginning = 10;
var charAtEnd = 7;
var myStr = "I have list of title in a drop-down as string example";
var finalOutput = "";
if (myStr.length > (charAtBeginning + charAtEnd)) {
  finalOutput = myStr.substring(0, charAtBeginning) + '..' + myStr.substring((myStr.length - charAtEnd), myStr.length);
}
alert(finalOutput);

