我正在製作一個拼圖網站,您選擇一個拼圖,我想知道是否有一種方式,而不是彈出框將它打印到網站上。我不介意,我們使用的是什麼代碼,因爲我能說流利的大多數,有沒有辦法可以打印此代碼而不是使用onclick?
這是我的代碼至今:
<body>
<script type="text/javascript">
function myFunction()
{
function ask() {
var a = (Math.round(Math.random()*1000000))
alert (a)
return prompt("What was the number?") == eval(a);
}
var questions = [ask(), ask(), ask(), ask(), ask()],
total = questions.length,
correct = questions.filter(Boolean).length;
alert("You got "+correct+"/"+total+" correct");
}
</script>
<button onClick="myFunction()">Remember the number</button>
</body>
<body>
<script type="text/javascript">
function myFunction2(){
function ask() {
var a = Math.floor(Math.random() * 10) + 1;
var b = Math.floor(Math.random() * 10) + 1;
var op = ["*", "+", "/", "-"][Math.floor(Math.random()*4)];
return prompt("How much is " + a + " " + op + " " + b + "?") == eval(a + op + b);
}
var questions = [ask(), ask(), ask(), ask(), ask()],
total = questions.length,
correct = questions.filter(Boolean).length;
alert("You got "+correct+"/"+total+" correct");
}
</script>
<button onClick="myFunction2()">Quick math</button>
</body>
</html>
</html>
所以我在想,如果有辦法使它顯示爲文本並在頁面上有一個文本框來輸入,該文本仍然有效。而且設計可以改變,所以我可以製作更大的文本框或更大的字體,所以它不僅僅是一個不可編輯的onclick。
所有幫助非常感謝。 謝謝。
看一看jQuery用戶界面對話框https://開頭jQueryUI的。 com/dialog/ – avrono
看看jquery'.append()'和'.remove()' – blgt
謝謝你們倆 – WTFreezer