- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在为我的侄子们写一个星球大战测验。在发布图片和问题后,我想清除屏幕并发布另一张图片和问题,但我似乎无法做到这一点。我哪里出错了?这是我到目前为止的代码。它基本上会同时打印两个问题。
<!doctype html>
<html>
<head>
<title> Star Wars Quiz</title>
<style>
body {
font-family:sans-serif;
text-align:center;
}
form {
margin:0 auto;
width:500px;
text-align:left;
}
</style>
</head>
<body>
<img src="http://i.imgur.com/xkdHqSM.jpg" width="500" height="500" />
<form name="form1" method="post" action="">
<p>What is this?</p>
<p>
<label><input type="radio" name="star" value="1"
onclick="answer(this);">The DeathStar</label>
</p>
<p>
<label><input type="radio" name="star" value="2"
onclick="answer(this);">Tatooine</label>
</p>
<p>
<label><input type="radio" name="star" value="3"
onclick="answer(this);">Peppa Pigs House</label>
</p>
</form>
<script>
var globalScore = 0;
function answer(selectedButton) {
var score = document.getElementById("score");
if (selectedButton.value == "1") {
//document.body.innerHTML = "";//clear screen
globalScore += 1;
}
score.value = globalScore;
}
</script>
<p id="quest2">
<img src="http://i.imgur.com/hee2oSS.png" width="500" height="500" />
<form name="form2" method="post" action="">
<p>What is this?</p>
<p>
<label><input type="radio" name="star" value="1"
onclick="answer(this);">a Bow Fighter</label>
</p>
<p>
<label><input type="radio" name="star" value="2"
onclick="answer(this);">a Tie Fighter</label>
</p>
<p>
<label><input type="radio" name="star" value="3"
onclick="answer(this);">a Street Fighter</label>
</p>
</p>
</form>
最佳答案
你可以使用这个..但我认为你想要遵循的方式变化很大并且对你的项目效率不高。但我已经更正了您的代码..请检查。
<!doctype html>
<html>
<head>
<title> Star Wars Quiz</title>
<style>
body {
font-family:sans-serif;
text-align:center;
}
form {
margin:0 auto;
width:500px;
text-align:left;
}
</style>
</head>
<body>
<div id="score"></div>
<div id="quest1">
<img src="http://i.imgur.com/xkdHqSM.jpg" width="500" height="500" />
<form name="form1" method="post" action="">
<p>What is this?</p>
<p>
<label><input type="radio" name="star" value="1"
onclick="answer(this);">The DeathStar</label>
</p>
<p>
<label><input type="radio" name="star" value="2"
onclick="answer(this);">Tatooine</label>
</p>
<p>
<label><input type="radio" name="star" value="3"
onclick="answer(this);">Peppa Pigs House</label>
</p>
</form>
</div>
<script>
var globalScore = 0;
function answer(selectedButton) {
var score = document.getElementById("score");
if (selectedButton.value == "1") {
//document.body.innerHTML = "";//clear screen
globalScore += 1;
}
score.innerHTML = globalScore;
document.getElementById('quest1').style.display='none';
document.getElementById('quest2').style.display='block';
}
</script>
<div id="quest2" style="display:none;">
<img src="http://i.imgur.com/hee2oSS.png" width="500" height="500" />
<form name="form2" method="post" action="">
<p>What is this?</p>
<p>
<label><input type="radio" name="star" value="1"
onclick="answer(this);">a Bow Fighter</label>
</p>
<p>
<label><input type="radio" name="star" value="2"
onclick="answer(this);">a Tie Fighter</label>
</p>
<p>
<label><input type="radio" name="star" value="3"
onclick="answer(this);">a Street Fighter</label>
</p>
</form>
</div>
关于javascript - 选择单选按钮后清屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21930800/
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: How can I clear the terminal in Ruby? 如何在 ruby 中清除终端
对不起,我刚刚开始学习clojure。我在 REPL CLI 中运行了很多命令。但现在我无法清除 CLI 屏幕。 cls 命令在 REPL 中也不起作用。提前致谢! 最佳答案 尝试按 Control-
如何在delphi控制台应用程序(delphi xe6或更高版本)中清除控制台屏幕我已经搜索了互联网和帮助文件,但似乎找不到它? 最佳答案 I am trying to find out if the
对于 Java Applets,“清除屏幕”的最佳方法是什么?是否有特定的功能,或者您会创建并绘制一个屏幕大小的白色矩形? 清除整个小程序屏幕的最佳做法是什么? 最佳答案 通常清除小程序的最佳做法是绘
他们是一种在 mac 上用 c++ 清除屏幕而不使用 系统(“清除”);命令?如果不是,他们是替换角色的方法吗? 最佳答案 如果您绝对不关心可移植性,只需发出与 clear 相同的字符序列即可。 $
您好,我正在尝试使用此代码在 DOS 视频模式下清除屏幕。 但是当我运行它时,点仍然在那里! org 100h mov ah, 0 ; set display mo
我是一名优秀的程序员,十分优秀!