<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<p><input type="text" name="jc" id="jc" placeholder="请输入数字" /></p>
<p><input type="button" id="sub" value="确定" onclick="myfun()"/></p>
<p>结果为:<span id="jg"></span></p>
<script type="text/javascript">
function myfun () {
var x=document.getElementById("jc").value;
var res=document.getElementById("jg");
var i=1;
var sum=1;
for (;i<=x;i++) {
sum=sum*i;
}
res.innerHTML=sum;
}
</script>
</body>
</html>