addClass is working in a place but not working in the other place


this code below in jQuery is working for the first addClass functiond but it says addClass is not a function in the second case inside the IF statement
`(document).ready(function(){ 'use strict'; // smooth scroll (‘nav ul li a’).click(function(e){
('body, html').animate({ scrollTop: (’#’+(this).data('scroll')).offset().top }, 1000); //(this).siblings().removeClass(‘active’);
(this).addClass('active'); }); // adding activ class /*(‘nav ul li a’).click(function(e){

// sync with scroll
        if($(window).scrollTop() > $(this).offset().top){
            var linkDat =$('nav a').data('scroll');
            var divid =$(this).attr('id');
            if(linkDat == divid ){