Reputation: 2494
I have two HTML files.
First:
<table>
<tr>...</tr>
<tr>...</tr>
<tr>...</tr>
<tr>...</tr>
<tr>...</tr>
<tr>...</tr>
...
</table>
Second:
<div=container>
<div>...</div>
<div>...</div>
<div>...</div>
<div>...</div>
<div>...</div>
...
</div>
table
and container
have more vertical size than the window. How can I get the current last tr(div) content displayed in the window?
Upvotes: 1
Views: 209
Reputation: 3877
There is a simple jQuery plugin here that checks if an object is visible on screen. You could cycle through each of the div
or tr
elements in reverse order, using that code to check if it's inside the current window, until you find the one that is visible on screen.
Upvotes: 4
Reputation: 1756
Using jquery you can use css3 selectors, so the following should work:
$("table > tr:last-of-type")
Similarly for the div:
$("div#container > div:last-of-type")
This will get the last element of type within the first element specified in the selector. If you actually want what is above the fold, this is not the solution
Upvotes: 0