I'm trying to use the jquery inview plugin to add a class to an element when it's within the viewport. For some reason the plugin in only adding the class to the very last element even though the other elements are clearly visible in the viewport. Below is my code:
html:
<div class="container-fluid">
<article class="entry"></article>
<article class="entry"></article>
<article class="entry"></article>
<article class="entry"></article>
<article class="entry"></article>
<article class="entry"></article>
</div>
jquery:
$(function() {
$('.entry').bind('inview', function (event, visible) {
if (visible) {
$(this).addClass('show-post');
}
});
});
Put you script inside ready:I'm changing the color to green to show the effect that the class
show-postis added.