2010-02-02 51 views
0

我是一個JavaScript初學者。我正在製作一個文字遊戲,這個遊戲顯示了一個線索(在一個骰子上)到一個單詞。現在我需要顯示單詞的空白處和它下面的線索。我不知道熱點內容顯示在我想要的頁面中?不知道如何將Javascript的輸出定位到HTML頁面

<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> 

回答

1

只是爲了開始,你可以創建一個<input type=text id=clue />和編輯它的內容通過運行

document.getElementById("clue").value= "___"; 

後來,你可以創建一個<div>,改變它的通過.innerHTML財產內容;

相關問題