Why doesn’t it fire the alert?
var $anchor = $(this);
$('.hide').val($(this).attr('href'));
$('html, body').animate({
scrollLeft: $($anchor.attr('href')).offset().left
}, {
queue: false,
duration: 1000,
easing: 'easeInOutCirc'
}, function () {
alert('test');
});
There are multiple different syntax options you can use with
.animate(). When you pass a properties object and an options object (like you are doing), the completion function goes in the options object not as the third parameter like this:This is described in full in the jQuery .animate() doc.