You need to decrement
your counters before you remove your classes like this:
function scrollMailUp(position) {
console.log(targetOptTop);
console.log(targetOptDown);
targetOptTop--;
targetOptDown--;
if (targetOptTop >= 1) {
$('.mailOpt:nth-child(' + targetOptTop + ')').removeClass('hide');
$('.mailOpt:nth-child(' + targetOptDown + ')').addClass('hide');
};
};
here is your fiddle