weixin_33708432 2014-12-12 23:40 采纳率: 0%
浏览 29

可存储2个变量的函数

I need to do a calculator and assume I have to click button to insert number to display box. For example click 3 and 2 the inputbox display 32 than i need to click "+" button. The add button is to remove the previous number and store it so that i can retype a new number(like a normal calculator do). After that I need to store 3 objects. Which is first input number, "+" and the second number. The reason of store those object is because i need to create the "=" button to send those number to php.

What i need to do and do i need to modify the code. P.S I m using ajax for the "=" function and send it to php. However, I didn't create it yet.

var memory = "";
    $("#add").click(function() {
                memory += $show.val() + "+";
                $show.val("");
            });
  • 写回答

1条回答 默认 最新

  • weixin_33691700 2014-12-12 23:50
    关注

    You could store the variables as an object, or array.

    var memory = {
     var1: 123,
     var2: 123
    }
    

    or

    var memory = [var1, var2];
    

    then you can grab either one when you need it.

    评论

报告相同问题?

悬赏问题

  • ¥15 ssh登录页面的问题
  • ¥60 渗透一个指定银行app,拿到客户信息,需要什么级别
  • ¥50 关于在matlab上对曲柄摇杆机构上一点的运动学仿真
  • ¥15 jetson nano
  • ¥15 :app:debugCompileClasspath'.
  • ¥15 windows c++内嵌qt出现数据转换问题。
  • ¥15 stm32 串口通讯过程中的问题
  • ¥20 公众号如何实现点击超链接后自动发送文字
  • ¥15 用php隐藏类名和增加类名
  • ¥15 算法设计与分析课程的提问