how can I get only the visible text in a scrollable div - just the part that does not have to be scrolled to.

how can I get only the visible text in a scrollable div - just the part that does not have to be scrolled to.

I have a div that I constrain to only be 400 pixels high, as follows:

  1. style="width:800px;height:400px;max-height:400px;overflow:scroll"

If the user scrolls through it, and then clicks a button, I'd like to know what text is visible at that point in the div.  I'm not talking about hidden versus non-hidden tags, I just want to know: what does he see when he looks at the div?

If I use the "text()" method, I get all the text in the div, not only the visible part.

Is there a way to do this?