Is it possible to change the array, trough which is looped with an external variable, which gives the array-name as string?
My example loops through the variable name itself. I guess this is just a syntax-question? Thanks a lot for your help.
HTML
<ul>
<li data-array="one">Array One</li>
<li data-array="two">Array Two</li>
<li data-array="three">Array Three</li>
</ul>
JS
var one = ['One-One','One-Two','One-Three'];
var two = ['Two-One','Two-Two','Two-Three'];
var three = ['Three-One','Three-Two','Three-Three'];
$('li').click(function(){
var selectedArray = $(this).attr('data-array');
for (var i = 0; i < selectedArray.length; i++) {
console.log(selectedArray[i]);
}
});