嗨,我已经做了很多搜索,但找不到任何具体的东西,或者我可以在我的示例中工作。想知道是否有人可以提供帮助。我以前从未使用过 javascript,但有人要求我进行评估以编写一个软件来跟踪十针保龄球游戏中的得分。我正在尽可能多地阅读,但有一些事情我仍在努力。我已经为玩家制作了一个表格来输入他们的名字,我希望能够在他们输入名字后隐藏表格,从而使界面看起来不那么混乱。尝试了很多方法,但似乎没有一个对我有用,我尝试将表单放在 div 中并使用 onClick 事件隐藏 div,但它似乎无法识别 div 等,正在寻找一些指针,
<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script class="jsbin" src="http://ajax.aspnetcdn.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<style>
article, aside, figure, footer, header, hgroup,
menu, nav, section { display: block; }
</style>
<style id="jsbin-css">
</style>
<script>
function myFunction()
{
document.getElementById("formy").innerHTML="My First JavaScript Function";
}
</script>
</head>
<body>
<p id="formy"><form>
<h1>Please enter player names!</h1>
<input id="player1" type="text" placeholder="Player 1" />
<input id="player2" type="text" placeholder="Player 2" />
<input id="player3" type="text" placeholder="Player 3" />
<input id="player4" type="text" placeholder="Player 4" />
<input id="player5" type="text" placeholder="Player 5" />
<input id="player6" type="text" placeholder="Player 6" />
<input type="button" value="Save/Show" onclick="insert(),close.this", />
</form></p>
<div id="display"></div>
<script>
var titles = [];
var names = [];
var tickets = [];
var player1Input = document.getElementById("player1");
var player2Input = document.getElementById("player2");
var player3Input = document.getElementById("player3");
var player4Input = document.getElementById("player4");
var player5Input = document.getElementById("player5");
var player6Input = document.getElementById("player6");
var messageBox = document.getElementById("display");
function insert ( ) {
titles.push( player1Input.value );
names.push( player2Input.value );
tickets.push( player3Input.value );
clearAndShow();
}
function clearAndShow () {
// Show our output
messageBox.innerHTML = "";
messageBox.innerHTML += "<td>*" + player1Input.value + "<br/><td/>";
messageBox.innerHTML += "*" + player2Input.value + "<br/>";
messageBox.innerHTML += "*" + player3Input.value +"<br/>";
messageBox.innerHTML += "*" + player4Input.value + "<br/>";
messageBox.innerHTML += "*" + player5Input.value + "<br/>";
messageBox.innerHTML += "*" + player6Input.value;
// Clear fields
titleInput.value = "";
nameInput.value = "";
ticketInput.value = "";
}
</script>
</body>
</html>