JSFiddle - React, Tailwind, and code Playground

by jahrichie

HTML

<div data-behavior="update-counts"> 
    Facebook
    <span>1</span>
</div>

JavaScript

$(function() {
  var autoinc = true;  
  $('[data-behavior~=update-counts]').on('click', function () {
    var   currentCount      =  $(this).find('span').html(),
          fakeIncremented   =  parseInt(currentCount) + 1;
        
    if (autoinc == true) {
          alert("true")
          $(this).find('span').html(fakeIncremented);
    } 
      else  {
          alert("false")
      }
     autoinc = false;      
  });
});