Dynamic navbar jquery addClass() not doing anything


So I honestly don't know what I'm doing wrong. I have a dynamic homepage which uses switch statements to change the content.

What I am trying to do is make the navbar get a class="active" when I'm on "that" page. I did search for a long time but I just couldn't get it to work.

My homepage.php:

if (!empty($_GET['page'])) {   switch ($_GET['page']) {   default;   include 'inc/pages/homepage.php';   break;
case 'inc/pages/homepage.php':   include 'inc/pages/homepage.php';   break;
case 'inc/pages/page2.php':   include 'inc/pages/page2.php';   break;   }   }else{   include 'inc/pages/homepage.php';   }
include 'inc/footer.php';

My navbar.php has this kind of links:


I have tried this code (I did link the Jquery.min.js):

$(document).ready(function(){   $('nav a').click(function(){   $('nav a').removeClass("active");   $(this).addClass("active");   });   });