修复: 将原来的 =  号修改成 <input type="button" onclick="resCalc()" value ="=" />,否则没有事件去激活JS计算方法:

 原文网址:http://www.w3school.com.cn/tiy/t.asp?f=html5_form_output

 

<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
function resCalc()
{
numA=document.getElementById("num_a").value;
numB=document.getElementById("num_b").value;
document.getElementById("result").value=Number(numA)+Number(numB);
}
</script>
</head>
<body>
<p>使用 output 元素的简易计算器:</p>
<form onsubmit="return false">
<input id="num_a" /> +
<input id="num_b" /> <input type="button" onclick="resCalc()" value ="=" />
<output id="result" onforminput="resCalc()"></output>
</form>

</body>
</html>