Ma9*_*9ic 2 javascript css stylesheet
我为一个网站提出一个问题,并希望var reltext中的正确/再次尝试的消息是不同的颜色,即绿色表示正确,红色表示错误,也可能是每个旁边的小png.
有任何想法吗 ?
<form name = "Q1">
<p>A local construction company has purchased 5 brand new diggers. Two of them have a telescopic jib. If a driver chooses a digger to use at random what is the probability it will have a telescopic jib?<br>
0/5
<input name = "rad1" type = "radio" class="radio" onclick = "getAnswer('1a', '1')">
1/5
<input name = "rad1" type = "radio" class="radio" onclick = "getAnswer('1b', '2')">
2/5
<input name = "rad1" type = "radio" class="radio" onclick = "getAnswer('1c', '3')">
3/5
<input name = "rad1" type = "radio" class="radio" onclick = "getAnswer('1d','4')">
<br><br>
</p>
<div id = "para"><div>
</form>
<script type = "text/javascript">
var reltext = [];
reltext[1] = "TRY AGAIN - 0/5 This would mean that there was no diggers with a telescopic jib."
reltext[2] = "TRY AGAIN - 1/5 This would mean that there was only 1 digger with a telescopic jib"
reltext[3] = "CORRECT - 2/5 This would mean that there was 2 diggers with a telescopic jib"
reltext[4] = "TRY AGAIN - 3/5 This would mean that there was 3 diggers with a telescopic jib."
function getAnswer(ans, rel) {
document.getElementById("para").innerHTML = reltext[rel];
if (ans == "1c") {alert ("Correct - Well done!")}
else {alert ("Incorrect - Try again")}
}
</script>
Run Code Online (Sandbox Code Playgroud)
您可能无法使用JavaScript(或其他任何内容)设置警报框的内容的样式.
一个很好的选择是使用像jQuery UI这样的框架,并使用模态对话框而不是JS警报.这是jQuery UI对话框的链接:http://jqueryui.com/demos/dialog/
| 归档时间: |
|
| 查看次数: |
246 次 |
| 最近记录: |