Is it possible to use a string from an elements CSS class as an array name?
I'm looking for a smarter way of storing default animations that may grow over time to include more options in the array.
Example
JavaScript (jQuery): -
var a1 = ['red', 'pink'];
var a2 = ['green', 'lime'];
var a3 = ['blue', 'cyan'];
$('ul li').click(function() {
arr = $(this).attr('class'); // Does this need to be converted?
$('div#sprite').css('background', arr[0]); // Is this kosher?
$('div#sprite p').css('color', arr[1]);
});
HTML: -
<div id='sprite'><p>Lorem ipsum...</p></div>
<ul>
<li class='a1'>Array 1</li>
<li class='a1'>Array 2</li>
<li class='a1'>Array 3</li>
</ul>
Thanks in advanced!