jQuery class attribute won't change?
Hi, when I click the link "Unapprove" an alert popup says "Ok". I want this to only happen once (as you can see, i change class name, but it doesn't work). Why ?
- <div class="comment">
- <h3>WarzMX says:</h3>
- <p>I really like jQuery, but when some error occurs I often find myself wasting hours upon hours trying to solve it, even days can go by at times. :(</p>
- <p><a href="#" class="delete">Delete</a> | <a href="#" class="unapprove">Unapprove</a> | <a href="#" class="spam">Spam</a></p>
- </div>
jQuery:
- <script type="text/javascript">
- $(document).ready(function(){
- $(".comment .unapprove").click(function(){
- $(this).attr('class','approve');
- alert('ok');
- });
- });
- </script>
If I write "alert('The class attribute is now:'+$(this).attr('class'));" it gives me that class attribute is "approve". So why am I able to get into this function everytime I click??