title: jQuery change css class
body: <p>I have a problem with one jQuery script. I use this code:</p>
  
  <pre><code>&lt;span class="follow" data-id="&lt;?=$m['id']; ?&gt;" &gt;&lt;/span&gt;
  </code></pre>
  
  <p>-</p>
  
  <pre><code>        $('.follow').click(function(){
  
          $.ajax({
              type: "POST",
              url:"../ajax/settings/follow.php", 
              async: false,
              dataType:'html',
              data: {'id':$(this).attr('data-id')},
              success:function(rs){
                 $(this).removeClass("follow"); 
                  $(this).addClass("unfollow"); 
  
              },
  
              error:function (xhr, ajaxOptions, thrownError){
                  alert("ERROR !!!");
                  alert(xhr.status);
                  alert(ajaxOptions);
                  alert(thrownError);
  
              }  
          });   
  
      });
  </code></pre>
  
  <p>After click the span with style image TICK changed to CROSS, and changed attr class to unfollow. After click unfollow class must change to follow, but not working.</p>
  
  <pre><code>        $('.unfollow').click(function(){
  
          $.ajax({
              type: "POST",
              url:"../ajax/settings/follow.php", 
              async: false,
              dataType:'html',
              data: {'id':$(this).attr('data-id')},
              success:function(rs){
                 $(this).removeClass("unfollow"); 
                  $(this).addClass("follow"); 
  
              },
  
              error:function (xhr, ajaxOptions, thrownError){
                  alert("ERROR !!!");
                  alert(xhr.status);
                  alert(ajaxOptions);
                  alert(thrownError);
  
              }  
          });   
  
      });
  </code></pre>
  
  <p>What's wrong? </p>
  
  <p>I apologize for my English!</p>