我有这个结构:
var data = {
'horizontal':{
'static':[1,3,5,7,9],
'dynamic':[2,4,6,8]
},
'vertical':{
'static':[1,3,5,7,9],
'dynamic':[2,4,6,8]
}
};
我有这个 HTML 对象:
Direction:
<select id="direction">
<option value="horizontal">Horizontal</option>
<option value="vertictal">Vertictal</option>
</select>
Type:
<select id="mytype">
<option value="static">Static</option>
<option value="dynamic">Dynamic</option>
</select>
我可以data.horizontal.static[2]
像这样访问吗?
var result = data.[ $('#direction').val() ].[ $('#mytype').val() ][2];
有什么办法吗?