I have this object and want to access the variable scrolled var scrolled = 10;
from the init
function within the scrollDown
function.
I am having trouble accessing the variable. How can I achieve this?
// Summary Screen Functions
var summary = {
init: function() {
var scrolled = 0;
$('.page-summary-action a').on('click', summary.continueToSummary);
$('.scroll-down').on('click', summary.scrollDown);
$('.scroll-up').on('click', summary.scrollUp);
},
scrollDown: function(e) {
e.preventDefault();
scrolled = scrolled + 300;
console.log('clicked');
$(".data-cards").animate({
scrollTop: scrolled
});
},
scrollUp: function(e) {
e.preventDefault();
console.log('clicked');
$(".data-cards").animate({
scrollTop: 15
});
}
};
summary.init();