怎么样在js中实现两个数字相加?
怎么样在js中实现两个数字相加?
<input type="text" id="a1" value="1"> +<input type="text" id="a2" value="1"> =
<input type="text" id="a3" readonly="true">
<br>
<input type="button" value="click" onclick="foo()">
<script>
function foo(){
a3.value = parseInt(a1.value) + parseInt(a2.value);
}
</script>