this不会自动传递给AJAX回调函数。您可以使用
context:参数告诉jQuery通过它:
$.ajax({ type: "POST", url: "/ajax/actions/tag.php", data: { 'for_user_id': for_user_id, 'wl_id': wl_id, 'wi_id': wi_id }, context: this, success: function(data){ $(this).text("You've tagged this"); $(this).closest('.gl_buttons_holder').toggleClass('gl_buttons_holder gl_buttons_holder_tagged'); $(this).closest('.gl_buttons').addClass('tagged'); } });


