wood burning stoves 2.0*
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


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Showing short text in div/span" Watch "Showing short text in div/span" New topic
Author

Showing short text in div/span

Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
Hi,
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.
Regards
Balaji


Spritle Software Blogs
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61316
    
  66

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] [Bear's FrontMan] [About Bear] [Books by Bear]
 
GeeCON Prague 2014
 
subject: Showing short text in div/span