标签:javascript html
提示用户输入两个数,然后输出用户输入的两数之和
第一次输入 ,输入处为空
第二个输入,输入处为默认27 (这里强调语句的使用)
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=GB2312"/>
<title> 3.1 让用户输入两个数字,然后输出相加的结果 </title>
</head>
<body style="overflow:auto;padding:0px;margin:0px;">
<div style="font-size:14px;font-weight:bold;color:white;font-family:Arial,宋体;background-color:#6090DA;padding:4px 10px;">
<script>
intA=prompt("请输入第一个数字",""); //这里初始没有显示
intB=prompt("请输入第二个数字",27); //这里初始会显示27
document.write("你输入的第一个数字是"+intA);
document.write("你输入的第二个数字是"+intB);
document.write("<br>两者和是"+(parseInt(intA)+parseInt(intB) ));
</script>
</div>
</body>
</html>
JavaScript-3.1--获取用户的输入,输出用户输入的两数之和---ShinePans,布布扣,bubuko.com
JavaScript-3.1--获取用户的输入,输出用户输入的两数之和---ShinePans
标签:javascript html
原文地址:http://blog.csdn.net/shinepan/article/details/30239075