jQuery: How to get scroll percentage

Published:
$(function()
{
    $(window).scroll(onWindowScroll);
}

function onWindowScroll()
{
    var scrollPercentage
      = ($(window).height() + $(document).scrollTop()) / $(document).height();
    console.info(scrollPercentage);
}