<script>
$(function(){
$("#btn").click(function(){
var a=parseInt($("#txt1").val());
var b=parseInt($("#txt2").val());
var num=a+b;
if(isNaN(num)){
alert("您输入的有误");
}
else{
alert(num);
}
});
});
</script>
<body>
<input id="txt1" type="text"/>
<input id="txt2" type="text"/>
<input id="btn" type="button" value="求和"/>
</body>