I have the following code to get the ID of a <a href="#ID"> </ a>
and go to their respective div <div id="" />
:
$('a[href=#certificados]').click(function(e){
e.preventDefault();
$("html, body").animate({ scrollTop: $('#certificados').offset().top }, 1000);
});
$('a[href=#team]').click(function(e){
e.preventDefault();
$("html, body").animate({ scrollTop: $('#team').offset().top }, 1000);
});
$('a[href=#house]').click(function(e){
e.preventDefault();
$("html, body").animate({ scrollTop: $('#house').offset().top }, 1000);
});
$('a[href=#contact]').click(function(e){
e.preventDefault();
$("html, body").animate({ scrollTop: $('#contact').offset().top }, 1000);
});
How could I optimize the code?