$('.vote-btn').click(function (e) { e.preventDefault(); $('.vote-btn i').removeClass('fa').addClass('far'); $('i', $(this)).removeClass('far').addClass('fa'); let voteType; if ($(this).hasClass('upvote')) { voteType = 1; } else { voteType = -1; } const voteCount = $('.vote-container span'); voteCount.text(parseInt(voteCount.text()) + voteType); const container = $('body > section.container'); voteCount.parent().append(''); $('.vote-container .fa-sync').fadeIn(); $.ajax({ url: '/projects/addVote/index', method: 'POST', data: { id: $('.vote-container').data('id'), type: voteType }, success: function (result) { if (result['type'] === 'success') { voteCount.text(result['voteCount']); container.prepend('