不知道如何在HTML页面中定位Javascript的输出
我是一个javascript初学者。我正在做一个文字游戏,显示一个单词的线索(在骰子上)。现在我需要显示单词的空格和下面的线索。我不知道热显示内容的地方,我想在页面不知道如何在HTML页面中定位Javascript的输出,javascript,dom,Javascript,Dom,我是一个javascript初学者。我正在做一个文字游戏,显示一个单词的线索(在骰子上)。现在我需要显示单词的空格和下面的线索。我不知道热显示内容的地方,我想在页面 <html> <head> <script type="text/javascript"> form1= document.forms[0]; function display() { words=new Array("Elephant","Tiger","Panther","Giraffe",
<html>
<head>
<script type="text/javascript">
form1= document.forms[0];
function display()
{
words=new Array("Elephant","Tiger","Panther","Giraffe","Zebra","Anaconda");
phrases=new Array("Largest Land Mammal","Striped Animal moving towards Extinction","Found in the Amazon Jungle","Found in Africa","It helps us Cross","Very Dangerous Reptile");
count = words[i].length;
while(count>0)
{
document.write("__")//to display the word with blank spaces
document.write(""); // space in between characters
count--;
}
}
function show_dice()
{
randomnumber=Math.floor(Math.random()*6);
i=randomnumber;
randomnumber = randomnumber + 1;
document.getElementById("myButton1").value=randomnumber;
document.getElementById("myButton1").disabled="disabled";
}
</script>
<link rel="stylesheet" type="text/css" href="keyboard.css">
</head>
<body>
<form>
<input type="button" id = "myButton1" name ="Button1" onclick="show_dice()" value="Click the Dice!!!">
<h1>Enter Your Guess For the Word Below</h1>
<h2> Clue to the Word is :</h2>
<input type="text" value="" class="keyboardInput">
</form>
</body>
</html>
form1=文件.表格[0];
函数显示()
{
单词=新数组(“大象”、“老虎”、“黑豹”、“长颈鹿”、“斑马”、“水蟒”);
短语=新阵列(“最大的陆地哺乳动物”、“走向灭绝的条纹动物”、“发现于亚马逊丛林”、“发现于非洲”、“帮助我们穿越”、“非常危险的爬行动物”);
计数=字数[i]。长度;
而(计数>0)
{
document.write(“\”)//以显示带有空格的单词
document.write(“”;//字符之间的空格
计数--;
}
}
函数show_dice()
{
randomnumber=Math.floor(Math.random()*6);
i=随机数;
随机数=随机数+1;
document.getElementById(“myButton1”)。值=随机数;
document.getElementById(“myButton1”).disabled=“disabled”;
}
输入您对下面单词的猜测
这个词的线索是:
刚开始,您可以创建一个
并通过运行
document.getElementById("clue").value= "___";
稍后,您可以创建
并通过.innerHTML
属性更改其内容 我建议你阅读,而不是回答你的问题。它解释了鲁本斯答案的“原因”,并为你提供了未来解决类似问题的知识