On scroll add class
Sun Sep 24 2023 15:56:00 GMT+0000 (Coordinated Universal Time)
Saved by
@sagarmaurya19
$(window).scroll(function() {
var winTop = $(this).scrollTop();
$('.insight_post_wrap .row').each(function() {
var eleID = $(this).attr('[data-attr="scroll"]');
var eleTop = $(this).offset().top - 56;
var eleHeight = $(this).height();
var eleTopOffset = eleTop + eleHeight;
$('.insight_post_wrap .post-side-menu ul>li>a').each(function() {
var linkID = $(this).attr('href').indexOf('#') && $(this).attr('href').split('#')[1];
if (linkID != undefined) {
if (eleID === linkID) {
if (winTop >= eleTop && winTop <= eleTopOffset) {
$(this).parent().addClass('bookmark-active');
} else {
$(this).parent().removeClass('bookmark-active');
}
}
}
});
});
});
content_copyCOPY
Comments