-2
对于div,溢出设置为自动。我如何获得向上滚动的div部分的高度,现在使用jQuery不可见。另外我怎样才能得到div的可见部分的高度。使用jquery滚动的内容高度
$(window).scroll(function() {
// calculate the percentage the user has scrolled down the page
var scrollwin = $(window).scrollTop();
var scrollArticle = $('.main').scrollTop();
var articleheight = $('.main').outerHeight(true);
var windowWidth = $(window).width();
if (scrollwin >= $('.main').offset().top) {
if (scrollwin <= ($('.main').offset().top + articleheight)) {
//I want this percentage to be calculated on current visible portion of div plus above scrolled portion that is not visible. ScrollArticle is giving 0 value.
$('.bar-long').css('width', ((scrollArticle + $(window).height())/articleheight) * 100 + "%");
} else {
$('.bar-long').css('width', "100%");
}
} else {
$('.bar-long').css('width',($(window).height()/articleheight) * 100 + "%");
}
});
我试过$('。idOfDiv')。scrollTop()。这是给0值。 –
如果您需要深入的帮助,您需要编辑您的问题以包含您的代码。没有看到你有什么,我无法帮助你 –