Q:

jQuery code to add/remove classes and change display not working?

I'm reverse engineering a bit of jQuery code I found that does EXACTLY what I want. It is supposed to change the thumbnail in #featured-navigation that's been clicked on to class="selected" while the others that are not clicked are just class="". 
It's also supposed to change the connected post (same id as the thumbnail's href) in #featured-post to style="display: block;" while the others are style="display:none;". 
I know enough about jQuery to know that it's simple, but I don't know enough to know how it works and how I'm supposed to use it. Yeeeeah, I'm just about clueless on jQuery.
So here's my jQuery, which is being called in the footer-
/* Featured Rotation */

var featuredContainer = $('div#featured-post > div');
featuredContainer.hide().filter(':first').show();

$('div#featured-navigation > a').click(function () {

    featuredContainer.hide();
    featuredContainer.filter(this.hash).show();
    $('div#featured-navigation > a').removeClass('selected');
    $(this).addClass('selected');
    return false;

}).filter(':first').click();

And this is my whole featured post code that is showing up properly (minus most of the finer styling, as of right now), but is not being affected by the jQuery. I think I have the divs and all set up right, but it's still not working... -
<div id="featured-navigation">
<?php
$featuredPostThumbs = new WP_Query();
$featuredPostThumbs->query('showposts=4&cat=9');
while ($featuredPostThumbs->have_posts()) : $featuredPostThumbs->the_post(); ?>
<a title="<?php the_title(); ?>" href=
<?php if( $featuredPostThumbs->current_post == 0 ) : ?>
"#featured-first"
<?php endif; 
if( $featuredPostThumbs->current_post == 1 ) : ?>
"#featured-second"
<?php endif; 
if( $featuredPostThumbs->current_post == 2 ) : ?>
"#featured-third"
<?php endif; 
if( $featuredPostThumbs->current_post == 3 ) : ?>
"#featured-fourth"
<?php endif; ?> >
<?php the_post_thumbnail( 'featured_thumb' ); ?>
</a>

<?php endwhile; 
wp_reset_postdata(); ?>
</div>
<div id="featured-post" class="clearfix">
<?php

$featuredPosts = new WP_Query();
$featuredPosts->query('showposts=4&cat=9');
while ($featuredPosts->have_posts()) : $featuredPosts->the_post(); ?>

<?php if( $featuredPosts->current_post == 0 ) : ?>
<div id="featured-first" style="display: block;">
<?php endif; 
if( $featuredPosts->current_post == 1 ) : ?>
<div id="featured-second" style="display: none;">
<?php endif; 
if( $featuredPosts->current_post == 2 ) : ?>
<div id="featured-third" style="display: none;">
<?php endif; 
if( $featuredPosts->current_post == 3 ) : ?>
<div id="featured-fourth" style="display: none;">
<?php endif; ?>
<div id="featured-left">
<?php the_post_thumbnail( 'featured' ); ?>
<h2><?php the_title(); ?></h2>
</div>
<div id="featured-right">
<?php the_excerpt(); ?>
<!-- by <?php the_author() ?> -->
<?php the_time('F jS, Y') ?>
</div>
</div>

<?php endwhile; 

wp_reset_postdata(); ?>
</div>

And this is my test site, where I'm fiddling with all that. There's lots of unfinished stuff on there right now, but all I need help with for now is getting this jQuery to work.
test.glutenfreemakeupgal.com/
Thank you SO much in advance!

A:

Thanks to all the helpful replies, I finally figured it out! And it's WORKING!! Here's the new complete contents of my functions.js-
(function ($) {
$(document).ready(function() {

/* Featured Rotation */

var featuredContainer = $('div#featured-post > div');
featuredContainer.hide().filter(':first').show();

$('div#featured-navigation > a').click(function () {

    featuredContainer.hide();
    featuredContainer.filter(this.hash).show();
    $('div#featured-navigation > a').removeClass('selected');
    $(this).addClass('selected');
    return false;

}).filter(':first').click();

});
}(jQuery));

I found the weird opening tags in this answer here- TypeError: 'undefined' is not a function (evaluating '$(document)') I don't 100% get why they had to do this, but it does seem to work just fine.
Thank you again, y'all!! As soon as I get to 15 rep I'll be upping your answers, because they were super duper helpful. I've been struggling to figure this out for days and you finally got me to the place where I could. Thank you! You ROCK!! :D

