您现在的位置是:首页 > 电脑技术查询 > web开发

哪位高手能帮小弟我看看,这两个变量为啥相等呢。

编辑:chaxungu时间:2022-10-02 23:16:09分类:web开发

谁能帮我看看,这两个变量为啥相等呢。。。
JScript codevar lasty=0;function show(){ var scrolltop=document.documentElement.scrollTop; var percent=0.1*(scrolltop-lasty); if(percent>0) { percent=Math.ceil(percent); } else { percent=Math.floor(percent); } lasty=lasty+percent; }

问题是:scrolltop和lasty为什么总是相等呢?

------解决方案--------------------
+1探讨
没有垂直滚动条的时候,document.documentElement.scrollTop为0,lasty也为0,故两者相等