Full Code below
I want to add a number from a variable to the incrimented variable, but they don't add. instead they get concatinated.
This line
countScroll-=parseInt(scrollWidth_g);
if "scrollWidth_g" is 300 and "countScroll" is 10, i get 10300 and i want 310;
$(document).ready(function(e) {
var countScroll = 10;
$(document).on('click', '.scroller_g_nav', function(){
var nav = $(this).attr('data-nav');
var scrollWidth = $('.scroller_g').attr('data-scrollwidth');
if (typeof scrollWidth == 'undefined'){
var scrollWidth_g = 200;
} else {
var scrollWidth_g = scrollWidth;
}
if (nav == 'left'){
countScroll-=parseInt(scrollWidth_g);
$('.scroller_g').animate({scrollLeft:countScroll},600);
} else {
countScroll+=scrollWidth_g;
$('.scroller_g').animate({scrollLeft:countScroll},600);
}
});
});