首页 > 编程语言 > 详细

JavaScript加法器

时间:2018-10-14 20:06:22      阅读:249      评论:0      收藏:0      [点我收藏+]
 1 <html>
 2     <head>
 3         <title>
 4             加法器
 5         </title>
 6         <meta charset="UTF-8">
 7         <style type="text/css">
 8     
 9         </style>
10         
11         <script type="text/javascript">
12         function jFq()
13         {
14             var shuru = document.getElementById("shuru").value;                //获取id
15             var jieguo = document.getElementById("jieguo");             //获取id
16             var result = 0;
17             while(shuru.indexOf("+") != -1)
18             {
19                 var z = shuru.indexOf("+");
20                 result = shuru.substring(0,z)*1;
21                 shuru = shuru.substring(z+1,shuru.length);
22             }
23             result = (shuru)*1 + result;
24             jieguo.value = result;
25         }
26         </script>
27     </head>
28 <body>
29     <div>
30     <form>
31     <input id="shuru" type="text" />
32     <input type="button" value="计算" onclick="jFq()" /><br />
33     输出结果:<br />
34     <input id="jieguo" type="text" />
35     </form>
36     </div>
37 </body>
38 </html>

 

JavaScript加法器

原文:https://www.cnblogs.com/cxwl/p/9787312.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!