This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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
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: 60810
    
  65

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]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Showing short text in div/span
 
Similar Threads
Problem displaying report using JSP
Scroll bar with data table
CSS Float - how to "turn off" for subsequent content
Javascript event handler executes twice
Adding html tags to script