問題:每當如果我有單個'='該變量將顯示並罰款..但它完全忽略了if語句。如果我只做雙'=='..變量不顯示,並且它轉到else狀態。讓我知道你是否看錯了。如果聲明與img.src
var pic1 = document.getElementById('team1pic').src;
var win1 = document.getElementById('wins').innerHTML;
if (pic1 == 'pens.jpg') {
document.getElementById('wins').innerHTML = PittWins;
} else {
document.getElementById('wins').innerHTML = 'no';
}
這裏是一些HTML來與它一起去,我有
<a class="dock-item" id="pens" href="#" onclick="document.getElementById('team1pic').src='pens.jpg'"><span>Pittsburgh Penguins</span><img src="pens.jpg" alt="Pittsburgh Penguins" /></a>`
然後
<th width="35%" ><img src=""/id='team1pic'></th>
由於某種原因,pic1的警報發出文檔url?我有team1pic設置改變onclick ..所以它沒有被定義,直到點擊 – Shawn 2011-02-06 23:00:02