In javascript, I want to make a counter that increases the value when you click a button.
When I click the add button the first time, the number doesn't increase.
But when I print the value to the console, the result increases.
The fiddle: http://jsfiddle.net/techydude/H63As/
$(function() {
var //valueCount = $("counter").value(),
counter = $("#counter"),
addBtn = $("#add"),
value = $("#counter").html();
addBtn.on("click", function() {
counter.html(value ++); //this value is not incremented.
console.log(value); //this value gets incremented.
return
});
});
How do I make the value show the same for both lines?