After each times click an increasing number?
I want after each times click value 2011
an increasing number, how is it?
Example:
$('button').click(function() {
var num = '2011';
var out = num ++1;
alert(num); // i want this ou开发者_C百科tput: 2012
});
var num = 2011;
$('button').click(function() {
num++;
alert(num); // i want this output: 2012
});
var num = '2011';
$('button').click(function() {
num++;
alert(num); // i want this output: 2012
});
Try this:
var num = '2011';
$('button').click(function() {
var out = num++;
alert(num);
});
var num
must be outside of the function, otherwise it will be 2011 again every time the function is run.num++1
should benum++
.
精彩评论