求解释 大神

来源:6-11 编程练习

ART原艺美学

2016-12-18 00:40

<!DOCTYPE html>
<html>
 <head>
  <title> new document </title>  
  <script type="text/javascript">
   function count(){
        var txt1   = parseInt( document.getElementById('txt1').value);//获取第一个输入框的值
        var txt2   = parseInt( document.getElementById('txt2').value);//获取第二个输入框的值
        var select = document.getElementById('select').value;//获取选择框的值
        var result = '';这里什么意思????????????怎么解释??
        switch (select)
         {
            case '+':
                result = txt1 + txt2;
                break;
            case '-':
                result = txt1 - txt2;
                break;
            case '*':
                result = txt1 * txt2;
                break;
            case '/':
                result = txt1 / txt2;
                break;  
         }
         document.getElementById('fruit').value = result;// 还有这里什意思求解释大神?、????
   }
  </script>
 </head>
 <body>
   <input type='text' id='txt1' />
   <select id='select'>
        <option value='+'>+</option>
        <option value="-">-</option>
        <option value="*">*</option>
        <option value="/">/</option>
   </select>
   <input type='text' id='txt2' />
   <input type='button' value='  =  '  onclick = "count()" />
   <input type='text' id='fruit' />   
 </body>
</html>

写回答 关注

2回答

  • zemj
    2016-12-18 10:59:17

    var result;是指提前声明result.

  • wooego
    2016-12-18 10:31:26

    我这里把var result = '';//这里什么意思????????????怎么解释??注释掉就可以了。Firefox浏览器。

JavaScript进阶篇

本课程从如何插入JS代码开始,带您进入网页动态交互世界

467393 学习 · 21877 问题

查看课程

相似问题