在我的JavaScript程序中,我在do-while循環中創建了提示對話框。提示應該運行直到用戶在提示中進入停止。當用戶在提示中輸入值時,它應該顯示在屏幕上,並且應該生成另一個提示。但在我的情況下,當我第一次輸入值提示時,會生成另一個提示而不顯示值。任何人都可以告訴我我的代碼有什麼問題嗎?JavaScript:如何在每次提示後顯示值
代碼:
<html>
<head>
<title>lab12</title>
</head>
<body bgcolor="#efe862">
<h3 id="txt1"></h3>
</body>
<script>
myFunction();
function myFunction() {
do {
var prom = window.prompt("Enter a text(stop to exit)");
} while(prom != "stop");
document.getElementById("txt1").innerHTML = "The text is: " + prom;
}
</script>
</html>
我裏面加做的,但仍然無法正常工作 – pari