This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes is it possible to count the number of lines in the div element? 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 "is it possible to count the number of lines in the div element?" Watch "is it possible to count the number of lines in the div element?" New topic
Author

is it possible to count the number of lines in the div element?

yuvaraj KumarAmudhan
Ranch Hand

Joined: Aug 22, 2009
Posts: 110
I have a div element and its innerHTML is some number of lines, loaded at runtime from the file.
i need to count the number of lines of that div element. i didn't get any idea about that!
idea please!

thanks
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15385
    
    6
It is not easy, since I doubt you are asking about counting breaks.

If the text is all the same size, you can probably look at line-height and text-size. With that you might be able to guess.

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63202
    
  69

That's a really odd thing to do. Why do you need to do this?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
yuvaraj KumarAmudhan
Ranch Hand

Joined: Aug 22, 2009
Posts: 110
i have to modify the particular line dynamically. thats why i need to count the lines in a div element.

thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63202
    
  69

Perhaps if you supply a little more detail, we can help. Identifying a passage by "line" is really difficult and probably non-deterministic.

Perhaps the passage that needs to be modified can be identified as a <span> or other element that'll make this a whole lot easier and less error-prone.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: is it possible to count the number of lines in the div element?
 
It's not a secret anymore!