如何判断div的滚动条是不是在最底部

解决方案 »

  1.   

    div  有这么3个属性:
    scrollTop:  滚动条距上边的距离,也就是实际滚动的距离
    scrollHeight: 这个div如果把滚动的部分展开总距离是多少。
    clientHeight: 客户端高度, 也就是你看得见的高度, 看不见的就得靠滚动了
    scrollHeight = clientHeight + scrollTop.
    靠这个关系就可以搞定了。
    给你个例子:<div style="width:100%; height: 300px; border: solid red 1px; overflow: scroll" 
    onclick="alert(this.scrollTop);alert(this.scrollHeight);alert(this.clientHeight);">
    hellol<br>hellol<br>hellol<br>hellol<br>
    hellol<br>hellol<br>hellol<br>hellol<br>
    hellol<br>hellol<br>hellol<br>hellol<br>
    hellol<br>hellol<br>hellol<br>hellol<br>
    hellol<br>hellol<br>hellol<br>hellol<br>
    hellol<br>hellol<br>hellol<br>hellol<br>
    </div>
      

  2.   

    这个东西我也是刚刚研究了一下, 你找个dhtml.chm参考手册就可以了, 我的资源里面有。 看看一个标签有什么属性, 然后就是试验, 一会儿就试出来了
      

  3.   

    if(pixelHeight + scrollTop >= scrollHeight){
        alert("到底了~");
    }else{
        alert("未到底~");
    }