我基本上创建了一个由两行组成的表,第一行检查用户输入是否正确,第二行显示一个按钮。 我在我的表的第一行里面的脚本函数中使用了以下代码来显示输出响应:
function checkUserInput() {
var userInput = document.getElementById("textInput").value;
var stringToCheckAgainst = random_images_array[num].split('.');
//this splits the item at the array index into an array, like so.
If the item is "apple.gif", the array reads ["apple", "gif"]
if (userInput == stringToCheckAgainst[0]) {
//user has inputted the correct string
//window.alert("user gave correct response!");
document.write("<p>" + txt.fontsize(5) + "</p>"); document.close();
} else {
//user has inputted an incorrect string
//window.alert("user gave incorrect response!");
document.write("<p>" + txt1.fontsize(5) + "</p>"); document.close();
}
}
</script>
但是此代码将删除整个页面(文档)。任何人都可以建议我如何只在我的页面(或表格)的顶部写入消息,并保持我的表格的第二行不变?