How to fix footer at bottom using Jquery?

Fixed footer at bottom of window using Jquery


 $(function () {
        function adjust() {
            var winH = $(window).height(),
                docH = $('document').height();

            if (docH > winH) {
                //leave it
            } else {
                $('.footer').addClass('fixedfooter');
            }
        }
        $(window).on('resize', adjust);
 adjust();
    })

Explanantion

  • $ (window).height() returns the height of the browser viewport.
  • $ (document).height() returns the height of entire HTML document.
  • .fixedfooter class will add to footer section when document height is less than window height.

Result

See the Pen Fixed footer at bottom of window by Vinothkumar (@fedtutorial) on CodePen.0

You may also like

Leave a Reply

Your email address will not be published. Required fields are marked *