Skip to content Skip to sidebar Skip to footer

Use JQuery Display A Text In A Limited Label

I have a label and it's length is limited. I want to do this: when the text's length is longer than the label, the end words of text will instead of '...' How can do this with jQue

Solution 1:

You can do this without JS.

label{
 white-space: nowrap;
 text-overflow: ellipsis;
 overflow:hidden;
}

Solution 2:

This can be done with pure CSS. For instance, use text-overflow:ellipsis;

You will get what you are looking for.

WORKING DEMO

The HTML:

<div style="position: absolute; left: 20px; top: 50px; 
  width: 120px; height: 50px; border: thin solid black;
  overflow: hidden; text-overflow: ellipsis">
  <nobr>This is a NOBR section</nobr>
</div>

The CSS:

div { position: absolute; left: 20px; top: 50px; width: 120px; height: 50px; border: thin solid black; overflow: hidden; text-overflow: ellipsis }

Hope this helps.


Post a Comment for "Use JQuery Display A Text In A Limited Label"