<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Javascript实现加法计算器</title>
</head>
<body>
<input type="text" id="txt1"/>+
<input type="text" id="txt2"/>
<input type="button" id="btn1" value="=" onclick="jiShu()"/>
<input type="text" id="txt3"/>
</body>
</html>
<script type="text/javascript" language="javascript">
function jiShu() {
//parseInt(string,radix)Javascript中类型转换radix代表需要的进制方式
document.getElementById("txt3").value = parseInt(document.getElementById("txt1").value, 10) + parseInt(document.getElementById("txt2").value, 10);
}
</script>