私は jquery の初心者で、ページのスクロールダウンが 50 を超えたときに div を画面の上にハングアップさせたいのですが、どうすればこれを達成できますか?
div は常に絶対的であり、固定されないようにしたいと考えています。
$(document).ready(function () {
$(window).scroll(function () {
if ($(window).scrollTop() > 50) {
$(".articlebutton").css("top", "0px"); //I want this value to change dynamically as the scrollbar moves down, so that the div stays on top of screen
} else {
$(".articlebutton").css("top", "-50px");
}
});
});