Skip to content Skip to sidebar Skip to footer

Getting A Div Scroll Position Using Javascript.

I have one button in a div tag. That div tag also has a vertical scroll bar. If I scroll that bar and click on the button which is inside that div, it should return the scroll pos

Solution 1:

The scrollTop property tells you the vertical scroll position:

document.getElementById("yourButton").onclick = function() {
   alert(document.getElementById("yourDiv").scrollTop); 
}

Post a Comment for "Getting A Div Scroll Position Using Javascript."