元素的樣式屬性是無法直接通過:對象.style.屬性來獲取(樣式在style屬性中設置) offset系列: offsetLeft:距離左邊位置的值 offsetTop:距離上面位置的值 offsetWidth:元素的寬(有邊框) offsetHeight:元素的高(有邊框) scroll系列: 滾 ...
元素的樣式屬性是無法直接通過:對象.style.屬性來獲取(樣式在style屬性中設置) offset系列: offsetLeft:距離左邊位置的值 offsetTop:距離上面位置的值 offsetWidth:元素的寬(有邊框) offsetHeight:元素的高(有邊框) scroll系列: 滾軸---滾出去 scrollWidth: 元素中內容的實際的寬(沒有邊框), 如果沒有內容就是元素的寬 scrollHeight: 元素中內容的實際的高(沒有邊框), 如果沒有內容就是元素的高 scrollTop: 實時獲取向上捲的距離的值 scrollLeft: 實時獲取向左捲的距離的值
<script> //div的滾動事件 my$("dv").onscroll = function () { console.log(this.scrollTop); }; </script>