How to use jQuery to switch divs on and off

By InvincibleM

Okay so I am looking at this website, http://codetunnel.net/, and I saw that it only used one page, but jQuery was used to display different divs, therefore making it feel like a multipage website. I tried using the jQuery in my codepen, but it never worked. Can someone help me understand how the jQuery works, and how i can implement it into my own sites? The jQuery looks like this:

$(function(){
				$("#nav-home").click(function(){
					$("#home").show();
					$("#projects").hide();
					$("#contact").hide();
					$(".selected").removeClass("selected");
					$("#nav-home").addClass("selected");
				});
				$("#nav-projects").click(function(){
					$("#home").hide();
					$("#projects").show();
					$("#contact").hide();
					$(".selected").removeClass("selected");
					$("#nav-projects").addClass("selected");
				});
				$("#nav-contact").click(function(){
					$("#home").hide();
					$("#projects").hide();
					$("#contact").show();
					$(".selected").removeClass("selected");
					$("#nav-contact").addClass("selected");
				});
			});

https://codepen.io/orchtechnerd/pen/dRzGZV // my codepen

Source: Stack Overflow

    

Share it with your friends!

    Fatal error: Uncaught Exception: 12: REST API is deprecated for versions v2.1 and higher (12) thrown in /home/content/19/9652219/html/wp-content/plugins/seo-facebook-comments/facebook/base_facebook.php on line 1273