jquery Add and Remove Classes?
- by Steven
Hello,
I need a script that adds a 2 to the end of a class in a div with the id .sideboxtopleft on clicking of a link with the id of posts.
<script>
    $(".posts").click(function () {
      if ($('.sideboxtopleft').is('#sideboxtopleft2')) {
          $('.sideboxtopleft').removeClass('2');
      }
      else{
          $('.sideboxtopleft').addClass('2');
      }
    });
</script>
<div id="sideboxtopleft" class="sideboxtopleft">
<a href="#post" id="posts"><h3>RECENT POSTS <div id="arrow" class="arrow"></div></h3></a>
</div>
<div id="sideboxtopright" class="sideboxtopright">
<a href="#comments" id="comments"><h3>RECENT COMMENTS <div id="arrow" class="arrow2"></div></h3></a>
</div>
However it doesn't seem to want to work properly. Any help?