ankush
01-27-2015, 06:20 AM
Hi Guys,
I want to add a class on a DIV, when it is visible to user.
It is working by defining scroll to 200 but it may not work if i have more content on top. So please tell me the simplest way to add class when the DIV is actually visible.
Please see this website for reference (animated content) gojavas . com
$(document).scroll(function() {
var scroll = $(this).scrollTop();
if (scroll >= 200) {
$(".circle").addClass("rect");
}
})
<div id="space"></div>
<div class="circle"></div>
I want to add a class on a DIV, when it is visible to user.
It is working by defining scroll to 200 but it may not work if i have more content on top. So please tell me the simplest way to add class when the DIV is actually visible.
Please see this website for reference (animated content) gojavas . com
$(document).scroll(function() {
var scroll = $(this).scrollTop();
if (scroll >= 200) {
$(".circle").addClass("rect");
}
})
<div id="space"></div>
<div class="circle"></div>