Sapan
Sapan

Reputation: 13

Auto hide div according to scroll viewport

I have Millions div row. I want to add active class 7 div in scrollbar viewport and remaining all div hide. when I scroll active state change according to scrollbar viewport. Items can be Millions in row. I need this for Improve loading time.

https://jsfiddle.net/sapans/afghq58e/3/

Upvotes: 1

Views: 292

Answers (1)

Udhay Titus
Udhay Titus

Reputation: 5869

<div>
<div class="a">
    A
</div>

.a {
height: 300px;
width: 300px;
background-color: green;
}

$(window).scroll(function() {

if ($(this).scrollTop()>0)
 {
    $('.a').fadeOut();
 }
else
 {
  $('.a').fadeIn();
 }
 });

Working example click here for jsfiddle

Upvotes: 1

Related Questions