JavaScript Multidimensional Arrays
Posted
by JasonS
on Stack Overflow
See other posts from Stack Overflow
or by JasonS
Published on 2010-05-11T07:59:55Z
Indexed on
2010/05/30
0:32 UTC
Read the original article
Hit count: 606
This wasn't the question I was going to ask but I have unexpectedly run aground with JavaScript arrays. I come from a PHP background and after looking at a few websites I am none the wiser.
I am trying to create a multi-dimensional array.
var photos = new Array;
var a = 0;
$("#photos img").each(function(i) {
photos[a]["url"] = this.src;
photos[a]["caption"] = this.alt;
photos[a]["background"] = this.css('background-color');
a++;
});
Error message: photos[a] is undefined. How do I do this? Thanks.
© Stack Overflow or respective owner