I am totally new in the Jquery framework. I have a navigation with three anchors. My idea is to do nice smooth scroll to all elements with ID. I found this piece of code
$('#up, #down').on('click', function(e){
e.preventDefault();
var target= $(this).get(0).id == 'up' ? $('#down') : $('#up');
$('html, body').stop().animate({
scrollTop: target.offset().top
}, 1000);
});
It is works perfectly on one element, but need i copy this code for all others IDs with different parameters? Or can i just rebuild this line of code with multiple arguments? How can i do this?