santa
santa

Reputation: 12512

Detect if first element is visible w/ jQuery

I have a div with an overflow set to hide elements.

<div style="overflow:hidden; height:40px">
    <div class="item">Item 1</div>
    <div class="item">Item 2</div>
    <div class="item">Item 3</div>
</div>

Is it possible in jquery to detect if the first item is visible or hidden? Is it possible to detect the same for the last item?

Upvotes: 0

Views: 122

Answers (1)

Greg Guida
Greg Guida

Reputation: 7512

use jQuery's .position to figure out if the offset of the element from the parent is greater than the height of the parent.

Code sample here

Upvotes: 1

Related Questions