css
.anchor_point_topmargin1 {display: block; position: relative; top: -150px; visibility: hidden;}
.anchor_point_topmargin2 {display: block; position: relative; top: -50px; visibility: hidden;}
jQuery
$('.anchor_point').addClass('anchor_point_topmargin1');
$(window).scroll(function () {
var scrollValue = $(document).scrollTop();
if (scrollValue == '0') {
//console.log(scrollValue);
$('.anchor_point').addClass('anchor_point_topmargin1');
$('.anchor_point').removeClass('anchor_point_topmargin2');
} else {
$('.anchor_point').removeClass('anchor_point_topmargin1');
$('.anchor_point').addClass('anchor_point_topmargin2');
};
});
References :
'jQuery' 카테고리의 다른 글
[jQuery] onBeforeUnload Event (0) | 2019.05.19 |
---|---|
[jQuery] 현재 스크롤값 가져오기(scroll) (0) | 2019.05.01 |
[jQuery] $(document).ready() vs window.onload (0) | 2019.04.29 |
[jQuery] How to smooth scroll to an id after clicking a link from another page (0) | 2019.04.27 |
[jQuery] lang() Selector (0) | 2019.04.27 |