Access Javascript variables dynamically

后端 未结 4 1566
刺人心
刺人心 2020-11-28 16:07

I know you might think this is a duplicate or a dumb question. But the answers doesn\'t help me.

Here\'s my simple problem:

var option1 = \"some text         


        
4条回答
  •  执笔经年
    2020-11-28 16:56

    Please try this one:

        option = new Array();
        option[1] = "some text";
        option[2] = "some text";
        option[3] = "some text";
        for(var i = 1; i < 4; i++)
        {
            alert(option[i]);   
        }
    

提交回复
热议问题