我写了一个小脚本来生成随机yes
或no
. 但是,它没有运行。完全没有。我的代码有什么问题?
这是一个 JSFiddle:http: //jsfiddle.net/u8ukp/
我的代码:
HTML:
<!DOCTYPE html>
<html>
<head>
<title>Should You? | A completely random decision</title>
<script type="text/javascript">
function func(){
var i = Math.random();
if (i >= 0.5) {
var e = document.getElementById('result');
e.InnerHTML = "Yes! :)";
}else{
var e = document.getElementById('result');
e.InnerHTML = "Nope! :("
};
};
</script>
</head>
<body>
<header>Should You?</header>
<br><br>
<a onclick="func();">Should You?</a>
<br><br>
<span id="result"></span>
</body>
</html>
谢谢!