您的位置:首页 > Web前端 > JavaScript

JavaScript写的数字加法

2015-11-07 16:04 537 查看


<!DOCTYPE html PUBLIC "-//W3C//DTDXHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<head>

<metahttp-equiv="Content-Type" content="text/html;charset=utf-8" />

<title>无标题文档</title>

<script>

window.onload=function (){

var otxt1=document.getElementById('txt1');

var otxt2=document.getElementById('txt2');

var obtn1=document.getElementById('btn1');

obtn1.onclick=function (){

alert(parseInt(otxt1.value)+parseInt(otxt1.value));

};

};

</script>

</head>

<body>

<input id="txt1"type="text" />

<input id="txt2"type="text" />

<input id="btn1"type="button" value="求和"/>

</body>

</html>

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: