首页 > 代码库 > JavaScript-3.1--获取用户的输入,输出用户输入的两数之和---ShinePans
JavaScript-3.1--获取用户的输入,输出用户输入的两数之和---ShinePans
提示用户输入两个数,然后输出用户输入的两数之和
第一次输入 ,输入处为空
第二个输入,输入处为默认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>
打开效果:
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。