var Mydata= [
{
value: 1,
label: "One"
},
{
value: 2,
label: "Two"
},
{
value: 3,
label: "Three"
},
{
value: 4,
label: "Four"
},
{
value: 5,
label: "Five"
}
];
我需要使用 js 或 jquery 动态创建它
最佳答案
In
loop
, pushobject
inarray
. To get equivalent of the number in words usetoWords.js
试试这个:
var len = 10;
var Mydata = [];
for (var i = 1; i < len; i++) {
Mydata.push({
value: i,
label: toWords(i.toString())
});
}
console.log(Mydata);
<script src="http://gh-canon.github.io/stack-snippet-console/console.min.js"></script>
<script src="http://javascript.about.com/library/toword.js"></script>
关于javascript - 如何在 javascript 或 jquery 中创建动态二维数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35569964/