我正在嘗試製作一個tic tac toe遊戲。我使用的是圖像而不是X和O,所以我需要在點擊圖像時填入圖像。我嘗試這樣做:我正在嘗試使用Javascript來顯示圖像
function makeDuck(place){
//this is just so I know the other methods work
alert("duck");
//This is the line I need help with
window.location.write('<img src="smallDuck.jpg" width="70" height="70"/>');
squares[place] = 1;
}
function makeBeaver(place){
//this is just so I know the other methods work
alert("beaver");
//This is the line I need help with
document.zero.write('<img src="smallBeaver.jpg" width="80" height="80"/>');
squares[place] = 2;
}
您可能想了解一些屬性和DOM操作以及更多JavaScript。 '.write'完全不能用於這種方式。 – Ryan
我同意,雖然首先跳進頭部的@minitech榮譽。我從這樣的嘗試中學到了最好的東西,而不是某個人出現,並告訴我如何做到這一點10倍更容易 – ZnArK
你可能想看看JSFiddle(http://jsfiddle.net/),它是一個偉大的,輕量級的方式快速原型化/測試JavaScript和CSS的各個部分。 – 5arx