In jQuery you can use $(this) inside the function call ajax post request after the response to the click?

Good afternoon. Tell me how can I access the element which was click after processing the data via ajax

$(document).ready(function(){

 $('.liketext').on('click', function(){

 counter = Number($(this).text());

 dataid = $(this).attr('data-id');

 var qdata = {
 id : dataid,
 cnt : counter
 } 

$.post('assets/components/ajax/like.php',qdata,function(data){
$(this).html(data);
});

 return false;
});

 });


In the data return processed data, but $(this) no longer refers to the tag which was click. Help solve the problem.
July 2nd 19 at 18:21
2 answers
July 2nd 19 at 18:23
Solution
$(document).ready(function () {

 $('.liketext').on('click', function () {

 var self = $(this),
 counter = Number($(this).text()),
 dataid = $(this).attr('data-id');

 var qdata = {
 id : dataid,
 cnt: counter
}

 $.post('assets/components/ajax/like.php', qdata, function ( data ) {
self.html(data);
});

 return false;
});

});
Ahead ))) - Kameron_Hilpert34 commented on July 2nd 19 at 18:26
Thank you so much for your fast and correct answer! - weldon commented on July 2nd 19 at 18:29
July 2nd 19 at 18:25
and if so ?

$(document).ready(function(){
 $('.liketext').on('click', function(){
 var elementThis = this ; 

// and then instead of this - use elementThis 

 });
Isn't it the same with the previous answer? - Kameron_Hilpert34 commented on July 2nd 19 at 18:28
: of course, just when I was writing my it was empty )) - weldon commented on July 2nd 19 at 18:31
: Okay, thanks, that also answered :) - weldon commented on July 2nd 19 at 18:34

Find more questions by tags jQuery