Simple Counter issue
Posted
by
TechyDude
on Stack Overflow
See other posts from Stack Overflow
or by TechyDude
Published on 2012-11-11T04:58:43Z
Indexed on
2012/11/11
4:59 UTC
Read the original article
Hit count: 316
JavaScript
|counter
I want to make a very simple counter that increases the value when you click a button. When I click the add button the first time, the number doesn't increase, however I console log the value which increases the result everytime. Any ideas?
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 ++);
console.log(value);
return
});
});?
© Stack Overflow or respective owner