Help with .click() and multiple clicks
Hi guys, I want to use .click() to toggle between two states, for example:
- <script type="text/javascript">
-
- $(function(){
-
- $('a.add').click(function(){
- $(this).removeClass().addClass('remove').html('remove');
- return false;
- });
-
- $('a.remove').click(function(){
- $(this).removeClass().addClass('add').html('add');
- return false;
- });
-
- });
-
- </script>
-
- <p>
-
- This is a test... <a href="#" class="add">Add me</a>
-
- </p>
In the above code, what I'm trying to do is toggle between the two css classes .add and .remove. The change is occurring in one direction only.
It seems to be a simple solution, but it's avoiding me at the moment.