jQuery has no innerHTML
, it has html()
instead.
A single =
is assigment, two ==
is non-strict comparison, three ===
is strict comparison.
There’s no need for the if/else here at all, just use the proper methods, like html()
with a callback
$( document ).ready(function(){
var stake_month = 0;
var profit_month = 0;
var month_games = "Games";
var month_hit = "Hit";
var month_stake = "Stake";
var month_profit = "Profit";
var games_month = 0;
var hit_month = 0 + "%";
$("#Games_Month").html(month_games);
$("#Hit_Month").html(month_hit);
$("#Stake_Month").html(month_stake);
$("#Profit_Month").html(month_profit);
$('#January').click(function(){
$('#Games_Month').html(function(_, html) {
return html === month_games ? games_month : month_games;
});
});
});
4
solved Why do my if/else statement not work?