我很努力,但沒有成功,得到一個變量,其中變量名稱是動態的GET值動態
var v_1playerName = document.getElementById("id_1playerName").value;
var v_2playerName = document.getElementById("id_2playerName").value;
for (i = 1; i <=5 i++) {
alert(window["v_"+i+"playerName"]);
}
這是可能的價值?
您試圖提醒字符串'v_1playerName'而不是變量的值。 – callback
你嘗試了'var windowName =「v _」+ i +「playerName」; alert(window [windowName]);'? – ochi
在這一點上,我只想知道變量的值。這是一個簡單的函數,就像這個代碼一樣,沒有別的。 –