为了账号安全,请及时绑定邮箱和手机立即绑定

运行不出来


  function count(){       var a=parseInt(document.getElementById('txt1').value);       var b=parseInt(document.getElementById('txt2').value);     var x=document.getElementById('selsect').value;

正在回答

2 回答

这个和我发的有什么区别吗?

0 回复 有任何疑惑可以回复我~

function count(){

      var mytxt1=document.getElementById("txt1").value;

      var mytxt2=document.getElementById("txt2").value;

      var mys=document.getElementById("select").value;

      var result="";

      switch(mys)

      {

          case "+":

              result=parseFloat(mytxt1)+parseFloat(mytxt2);

              break;

            case "-":

              result=parseFloat(mytxt1)-parseFloat(mytxt2);

              break;

            case "*":

              result=parseFloat(mytxt1)*parseFloat(mytxt2);

              break;

           case "/":

              result=parseFloat(mytxt1)/parseFloat(mytxt2);

      }

      document.getElementById("fruit").value=result;

   }


0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
JavaScript进阶篇
  • 参与学习       467316    人
  • 解答问题       21875    个

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

进入课程

运行不出来

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信