javascript - How to achieve floating div on scrolldown -


i newbie on jquery, , want div hang on top of screen when page scrolldown more 50, how can achieve this?

i want div absolute , not fixed.

http://jsfiddle.net/8uccy/

$(document).ready(function () {     $(window).scroll(function () {           if ($(window).scrolltop() > 50) {               $(".articlebutton").css("top", "0px"); //i want value change dynamically scrollbar moves down, div stays on top of screen           } else {               $(".articlebutton").css("top", "-50px");           }      }); }); 

you can set position top -100 since -50 , scroll occurs after 50:

$(".articlebutton").css("top", ($(window).scrolltop()-100)+"px"); 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -