在名称中间使用迭代器迭代变量名 [英] iterate variable name with iterator in the middle of the name
本文介绍了在名称中间使用迭代器迭代变量名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在jquery中有4个变量叫做qual1p,qual2p,qual3p和qual4p。
我想在for循环中为它们赋值。
类似
I have 4 variables in jquery called qual1p, qual2p, qual3p and qual4p.
I want to assign values to them inside a for loop.
something like
for (var i = 0; i < blue.length; i++) {
qual?p = blue[i][5];
}
如何编码质量?p这样?是我?
谢谢
how do I code qual?p so that ? is i ?
Thanks
推荐答案
这里有几条建议,http://stackoverflow.com/questions/3834373/how-to-reference-a-variable-dynamically -in-javascript [ ^ ]。
我相信对象是您可能想要使用的对象。
There are several suggestions here, http://stackoverflow.com/questions/3834373/how-to-reference-a-variable-dynamically-in-javascript[^].
I believe the object one is the one you'll likely want to use.
>
这篇关于在名称中间使用迭代器迭代变量名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文