如何删除表格的一部分以显示消息而不触及其余部分?

时间:2015-07-22 17:07:38

标签: javascript html web

我基本上创建了一个由两行组成的表,第一行检查用户输入是否正确,第二行显示一个按钮。 我在我的表的第一行里面的脚本函数中使用了以下代码来显示输出响应:

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>

但是此代码将删除整个页面(文档)。任何人都可以建议我如何只在我的页面(或表格)的顶部写入消息,并保持我的表格的第二行不变?

0 个答案:

没有答案