我看不出爲什麼我的if/else語句無法正常工作?爲什麼我的if/else語句不起作用?
的JavaScript
var month_games = "Games";
var month_hit = "Hit";
var month_stake = "Stake";
var month_profit = "Profit";
var games_month = 0;
var hit_month = 0 + "%";
var stake_month = 0;
var profit_month = 0;
$(document).ready(function(){
document.getElementById("Games_Month").innerHTML = month_games;
document.getElementById("Hit_Month").innerHTML = month_hit;
document.getElementById("Stake_Month").innerHTML = month_stake;
document.getElementById("Profit_Month").innerHTML = month_profit;
});
$('#January').click(function(){
if ($('#Games_Month').innerHTML = month_games)
{$('#Games_Month').innerHTML = games_month;}
else {$('#Games_Month').innerHTML = month_games;}
});
HTML
<table class="table">
<thead>
<tr id="January">
<th>January</th>
<th id="Games_Month"></th>
<th id="Hit_Month"></th>
<th id="Stake_Month"></th>
<th id="Profit_Month"></th>
</tr>
</thead>
現在,當我點擊#january
,我想的其它ID的改變到另一個變量是什麼inner.HTML,但點擊時再次,將其改回。
我的代碼有什麼問題?
因爲jQuery沒有'innerHTML'? – adeneo
'='是賦值運算符,您應該在'if'語句中使用'=='或'==='作爲等號運算符 –