always,visible,div,show,always,top

Kubilay 7/27/2016 0

this code will let you show selected div on top and always visible

JavaScript
 var top = $('.js-control').offset().top;

    $(document).scroll(function () {
        $( '.js-control').css('position' , '' );
        top = $( '.js-control').offset().top;
        $( '.js-control').css('position' , 'absolute' );
        var calculatedTop = Math.max(top, $(document).scrollTop());
        if (calculatedTop < 100) {
            $( '.js-control').css('top' , '0' );
            $( '.js-control').css('position' , '' );
        }
        else {
            $( '.js-control').css('top' , calculatedTop);
        }
    });
 

Report Bug

Please Login to Report Bug

Reported Bugs

Comments

Please Login to Comment

Comments