Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $.fn.followTo = function (pos) {
- var $this = this,
- $window = $(window);
- $window.scroll(function (e) {
- if ($window.scrollTop() > pos) {
- $this.css({
- position: 'fixed',
- top: 0
- });
- } else {
- $this.removeAttr('style');
- }
- });
- };
- // Calling the function
- $('#div').followTo(50);
Add Comment
Please, Sign In to add comment