on click add class not working?

on click add class not working?

hello.

im building an image slider and i can't get the addClass to work when you click on a nav bullet button.

this code adds a image to each li (for each image in the slider)

  1. $(document).ready(function() {
                $('.carousel_data .carousel_item').each(function(index){   
                    $('#carousel-btns ul li').append('<a class="navItem"><img src="images/non-active-btn.png"></a>');
                });



that gives me:

<div id="carousel-btns">
<ul>
      <li>
            <a class="navItem">
      </li>
      <li>
            <a class="navItem">
      </li>
</ul>
</div>

then for each li i want to add a selected class if its clicked on


  1. $('li a.navItem').click(function(){
                    $('li a.navItem').removeClass('selected');
                    $($this).addClass('selected');   
                });



when i click i get nothing ?

thanks
ricky