如何在javascript中按以下方式进行多维数组 [英] how to multidimesional array as follows in javascript
本文介绍了如何在javascript中按以下方式进行多维数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想做数组 像这样
var ImageArray = [
{image:"/image1.jpg"},
{image:"/image1.jpg"},
{image:"/image1.jpg"}
]
我想使用jquery的每个功能从包含图像的div中制作数组的上述结构.
I want to make above structure of array from div containing images using each function of jquery.
这样我就可以像ImageArray[index].image
推荐答案
var ImageArray = [];
$('div img').each(function(){
ImageArray.push({image:this.src});
});
应更改选择器的div
部分,以匹配要用作容器的div.
this div
part of the selector should be altered to match the div you want to use as the container..
这篇关于如何在javascript中按以下方式进行多维数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文