Get element's ID and set it as variable

前端 未结 6 1491
执笔经年
执笔经年 2020-12-02 02:18

I have a button:

6条回答
  •  情深已故
    2020-12-02 02:32

    You can use and object to store your variables in:

    var variables = {};
    

    to add a variable just type:

    variables[name] = value;
    

    and to access the value:

    variables[name] 
    

    Check it out here: jsFiddle

    Button 2 reads the value of variables[formid] and button 1 sets formid to submitted

提交回复
热议问题