慕容7034939
2016-12-14 18:26
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8"/>
<title></title>
<script>
window.onload=function ()
{
var oTxt1=document.getElementById('txt1');
var oTxt2=document.getElementById('txt2');
var oBtn=document.getElementById('btn1');
oBtn.onclick=function ()
{
alert(oTxt1.value+oTxt2.value)
}
}
</script>
</head>
<body>
<input class="txt1" type="text"/>
<input class="txt2" type="text"/>
<input id="btn1" type="button" value="求和"/>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8"/>
<title></title>
<script>
window.onload=function ()
{
var oTxt1=document.getElementById('txt1');
var oTxt2=document.getElementById('txt2');
var oBtn=document.getElementById('btn1');
oBtn.onclick=function ()
{
alert(oTxt1.value+oTxt2.value)
}
}
</script>
</head>
<body>
<input id="txt1" type="text"/>
<input id="txt2" type="text"/>
<input id="btn1" type="button" value="求和"/>
</body>
</html>
JavaScript入门篇
739822 学习 · 9566 问题
相似问题