I have what I believe is a somewhat basic question about arrays in jQuery, but I'm stumped- what I'd like to be able to do is create a number of arrays of DOM elements, each equal in their index numbers, access their index, and then perform jQuery methods according to that index.
For instance, I would like to perform a click action on member i of the first array, and that i would target the corresponding i of the other array members. So, in the following example, clicking arrayOne[1] would only affect arrayTwo[1] and arrayThree[1], clicking arrayOne[2] would only affect arrayTwo[2], arrayThree[2] and so forth.
I've tried using a "for loop", .each() method, .map() and played with the jQuery.each() method, but nothing is working. Either all key/value members are affected, or only one key/value member is affected. Because I've tried so many things, I'm giving a representative problem set, rather than a specific one, and hopefully this will be sufficient to suss out my problem.
var arrayOne=['.selectorOne_a', '.selectorOne_b', '.selectorOne_c'];
var arrayTwo=['.selectorTwo_a', '.selectorTwo_b', '.selectorTwo_c'];
var arrayThree=['.selectorThree_a', '.selectorThree_b', '.selectorThree_c'];
for(i=0; i<=arrayOne.length-1; i++){
$(arrayOne[i]).click(function(){
$(arrayTwo[i]).show();
$(arrayThree[i]).hide();
});//click
}
I realize a for loop isn't the correct way of doing this, but it's meant as a representative method I've tried...Should be simple, right? I don't know whether this would fall under the rubric of a multidimensional array, hash, what-have-you, so any advice or links to tutorials on navigating these concepts would be greatly appreciated as well. I hope this makes sense, and I'd appreciate any advice given.
Thanks!
[].arrayOne-1is that what you have or is itarrayOne.length-1?