matt matt - 5 months ago 17
HTML Question

Increment a number inside a div?

i have this

<div class="likes">13</div>


and I want to increment this number by +1 when I click a button

How can I do that with jQuery?

$('btn').click(function() {
$('.likes').text();
});

Answer Source
$('btn').click(function() {
  var el = parseInt($('.likes').text());
  $('.likes').text(el+1);
});

http://jsfiddle.net/jg5GA/