Get element's ID and set it as variable

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

I have a button:

6条回答
  •  南笙
    南笙 (楼主)
    2020-12-02 02:34

    Your best option for archieving what you really want is using eval(), like this:

    eval("var " + currForm.attr('id');
    

    Check this link ->

    Dynamic Variables in Javascript

提交回复
热议问题