0
我試圖從最終結果發送按鈕到新的輸入框,但不知道。 我已經嘗試了幾件事情。如何將按鈕發送到輸入框?
首先
for (i=0;i<res.length;i++) {
var newbutton = document.createElement("BUTTON");
var t = document.createTextNode(" "+res[i]);
newbutton.appendChild(t);
newbutton.style.marginRight = "10px";
document.body.appendChild(newbutton);
document.getElementById("demo").addEventListener("click",ansFunction);
function ansFunction() {
document.getElementByid("demo").innerHTML = "answers";
}
}
二
for (i=0;i<res.length;i++) {
var newbutton = document.createElement("BUTTON");
var t = document.createTextNode(" "+res[i]);
newbutton.appendChild(t);
newbutton.style.marginRight = "10px";
document.body.appendChild(newbutton);
newbutton.onclick = "ansFunction";
function ansFunction() {
document.getElementByid("demo").innerHTML = "answers";
}
}
,但他們不工作。 預先感謝您。
'res'的值是多少? – RamenChef
'function myFunction(){ var str = document.getElementById(「input」).value; var res = str.split(「」); shuffle(res); document.getElementById(「demo」)。innerHTML =「」;'這裏是。我打亂了輸入值 –
並定義了'shuffle()'?如果是這樣,它有什麼作用? – RamenChef