title: Increment an element's value through JavaScript
body: <p>I have a like system on my website; and when somebody clicks the like button, I want the number of likes to go up 1 dynamically.</p>
  
  <p>For this; I used an Ajax call which works fine.
  Once the Ajax call is past, I want it to increment the elements value by one :</p>
  
  <pre><code>$(document).ready(function(){
    $('.likebutton').on('click', function() {     
      var a = $(this).attr('name');           
      var b = a.slice(4, 99);                 
      var c = "opim" + b;
      var d = 1;
      $.post('like.php', {i: b}, function(data) {
        $('.likebutton[name=' + a +']').replaceWith( "&lt;i name=\"like$i\" class=\"fa fa-heart likebuttono thisi3\" style=\"color:red\"&gt;&lt;/i&gt;&lt;/br&gt;Aimé!" );  
        document.getElementById(c).innerHTML = parseInt(document.getElementById(c).innerHTML,10) + d;
      });
    });
  });
  </code></pre>
  
  <p>This works; but sometimes, instead of adding 1, it adds 2 or 3 to the number of likes.</p>
  
  <p>Can anybody explain why it does this and how to fix this ?</p>