嘿,我是javasript / html的新手,我正在尝试建立一个扰乱预定义词之一的网站。然后显示加扰的单词和两个按钮。 一个按钮是加载一个新单词,另一个按钮是显示原始单词。一切似乎都工作正常,而不是显示正确的单词按钮"。这是我到目前为止所得到的。我删除了一些让它更好的东西
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript">
function Ausgabe() {
document.getElementById("Testerest") = WortArbeit;
}
</script>
</head>
<body>
<h1> Wortfluessigkeit</h1>
<script language=JavaScript type="text/javascript">
var Wort=new Array("DRACHENZAHN");
var rand=0; // normally random number
var WortArbeit = Wort[rand]; // word that gets changed
var Laenge = Wort[rand].length; // lenght of the word
var WortTemp = new Array([Laenge]); // word that gets scambled
var Moeglichkeit = new Array([Laenge]); // stores position of letter
for (var i = 0; i < Laenge ; i++) {
WortTemp[i] = Wort[rand][i];
Moeglichkeit[i] = i;
}
shuffleArray(WortTemp,Moeglichkeit);
function shuffleArray(arr,arr2){
for (var i = arr.length; i--;){
var sIndex = Math.floor(Math.random() * (i + 1));
var h = arr[i];
var j = arr2[i];
arr[i] = arr[sIndex];
arr2[i] = arr2[sIndex];
arr[sIndex] = h;
arr2[sIndex] = j;
}
return arr;
return arr2;
}
document.write(WortTemp.join(""));
document.write("<br>");
</script>
<main>
<form>
<button class="link">Neustart</button>
<button onclick="Ausgabe" id="Testerest" >Loesung</button>
<label>Originalwort:
<output id="AusgabeWort"></output>
</label>
</main>
</form>
</body>
</html>
我希望最初选择的,未加扰的单词在id = AusgabeWert的输出中显示,但是当我点击按钮时,整个东西再次加载。