here you go, i´d rather take a string representation of the id and concatinate the selector, it works fine !
jQuery(document).ready(function($) {
$(".scrollto").click(function(event) {
event.preventDefault();
var defaultAnchorOffset = 0;
var anchor = $(this).attr('data-attr-scroll');
var anchorOffset = $('#'+anchor).attr('data-scroll-offset');
if (!anchorOffset)
anchorOffset = defaultAnchorOffset;
$('html,body').animate({
scrollTop: $('#'+anchor).offset().top - anchorOffset
}, 500);
});
});
i think it didnt work cause you tryed to cast an object from a string
heres a fiddle, have fun !