Add content via an Array

Using the jquery index function

by aaronk85

HTML

<div>
    <div id="SP_Away_FP_1"></div>
    <div id="SP_Away_FF_1"></div>
    <div id="SP_Away_FP_2"></div>
</div>

JavaScript

var SP_selectedPlayers = new Array(
['SP_Away_FF_1','K. Height'],
['SP_Away_FP_1','B. Murray'],
['SP_Away_FP_2','D. Ismail']
);

      jQuery(document).ready(
        function() {
                    var index;
                    for (index in SP_selectedPlayers ) {
                     jQuery('#' + SP_selectedPlayers[index][0]).html(SP_selectedPlayers[index][1])
                    }
                }
      );