jQuery in Action, 3rd edition
The moose likes HTML, CSS and JavaScript and the fly likes Showing short text in div/span Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Showing short text in div/span" Watch "Showing short text in div/span" New topic

Showing short text in div/span

Balaji Loganathan
author and deputy

Joined: Jul 13, 2001
Posts: 3150
I have a long text like this "Hello this is a long text and this is a very long text, it can be one line or blah blah."

Now i would like to show it "Hello thi"<a href="#">more..</a>.

Click the more will show the complete text as tip or div popup.
Now could someone please tell me how to shorten the text to certain length using CSS or Javascript?
Is it possible ?
Thank you.

Spritle Software Blogs
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63548

Well you could certainly write a bunch of JavaScript to go through the page during onload and to shorten text content (perhaps identified via CSS class names), replacing it with the shorter text and link. But it strikes me that this would be much easier to accomplish on the server side with a JSP cutom tag or ilk.

Are you not using a server-side language?

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link: http://aspose.com/file-tools
subject: Showing short text in div/span
jQuery in Action, 3rd edition