Increment a text field value
Not a question that fits CR well. This is clearly short, untested sample code. You need $("#counter"), not $(".counter").



var counter = $("#counter")
counter.html( parseInt(counter.html()) + 1 )
&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
&lt;div id="counter"&gt;1&lt;/div&gt;




If you truly wish to increase the content of a field that you access by id you could try this:



document.getElementById('counter').textContent++;
&lt;div id="counter"&gt;1&lt;/div&gt;




This works as of IE9.. Personally I would always make sure that there is a number in textContent since otherwise the value will become NaN which looks like amateur hour.