jquery scroll to element toggle menu item 1

jquery scroll to element toggle menu item

$('.scrollto').click(function() {
	$('.article-aside__li').removeClass('is-active');
    $('html, body').animate({
        scrollTop: eval($('#' + $(this).attr('target')).offset().top - 10)
    }, 1000);
	$(this).parent('li').toggleClass('is-active');
	console.log(this);
});

Here is what the above code is Doing:
1. When the user clicks on a link with the class “scrollto”, the page will scroll to the element with the ID of the link’s “target” attribute.
2. The page will scroll to the element with the ID of the link’s “target” attribute minus 10 pixels.
3. The page will scroll to the element with the ID of the link’s “target” attribute over the course of 1 second.
4. The link’s parent element will have the class “is-active” added to it.

Similar Posts