Hi I'm creating a button that when pushed will scroll the contents of an element.
BUT it doesn't actually scroll the contents, instead it resets the padding-top attribute. I'm doing this because the normal javascript scroll functions require a height to be specified of the element. Or at least everyone that I've come across does.
So far I have this (below) which works :
var scrollLength = 55;
function scrollDown() {
scrollLength += 2;
document.getElementById('page').style.paddingTop=scrollLength.toString() + "px";
}
Question
Tanoru
Hi I'm creating a button that when pushed will scroll the contents of an element.
BUT it doesn't actually scroll the contents, instead it resets the padding-top attribute. I'm doing this because the normal javascript scroll functions require a height to be specified of the element. Or at least everyone that I've come across does.
So far I have this (below) which works :
var scrollLength = 55; function scrollDown() { scrollLength += 2; document.getElementById('page').style.paddingTop=scrollLength.toString() + "px"; }The issue is that it doesn't continuously scroll whilst I hold down the element, how do I do this?
Link to comment
Share on other sites
14 answers to this question
Recommended Posts