使用 $.each() 引用对象中的数组?
Referencing arrays in object using $.each()?
这段代码;
$.each( formValues, function(index, array) {
console.log("index: ",index," array: ",array);
});
在控制台输出这个;
index: 0 array: {name: "check2", value: "checked"}
index: 1 array: {name: "text1", value: "4"}
如何调整每个语句,以便我可以在记录的数组中单独定位 'name' and\or 'value' 值?
提前致谢。
使用.
从对象
访问值
$.each(formValues, function(index, array) {
console.log(array.name); // will output name
console.log(array.value); // Will output value
});
这段代码;
$.each( formValues, function(index, array) {
console.log("index: ",index," array: ",array);
});
在控制台输出这个;
index: 0 array: {name: "check2", value: "checked"}
index: 1 array: {name: "text1", value: "4"}
如何调整每个语句,以便我可以在记录的数组中单独定位 'name' and\or 'value' 值?
提前致谢。
使用.
从对象
$.each(formValues, function(index, array) {
console.log(array.name); // will output name
console.log(array.value); // Will output value
});