First, I would change up your html just a little bit like this:
<nav class="main-nav">
<ul>
<li><span data-content="#home">Home</span></li>
<li><span data-content="#work">Work</span></li>
<li><span data-content="#contact">Contact</span></li>
</ul>
</nav>
Now each span has a way to reference its element you want to show.
$( document ).ready(function() {
$('.page').hide();
$('#home').show();
});
ID attributes should be unique, so there is no reason you need to do div#id
, you can just do #id
Now for the dynamic part:
$('.main-nav').find('span').on('click', function()
{
$('.page').hide(); //hide all the content
$( $(this).attr('data-content') ).show(); //grab the reference we set up in data-cotnent and show that element.
}
)};