【发布时间】:2012-05-01 19:50:36
【问题描述】:
我正在尝试在 jQuery 中创建一个数组,该数组通过循环填充。
count = jQuery('#count_images').val();
通过上面的代码,我得到一个整数值(例如 5)。 我想知道的是如何在 jQuery 中做这样的事情:
int arrLength = count;
string[] arr1 = new string[arrLength];
int i = 0;
for (i = 0; i < arr1.Length; i++){
arr1[i] = i;
}
所以最后我的数组(例如 5)看起来像这样:[1,2,3,4,5]。
【问题讨论】:
-
我做到了,但这不是我想要的。无论如何,我使用了 dknaack 的解决方案,这对我来说效果很好。无论如何,谢谢。