how can i manage the array to restart from 0 (in function get_hover_color) when there are too many links and color array is too short?
thanks for helping!
till.
<div class="line">
<div><h2 class="color_link">DRUCKVORSTUFE</h2></div>
<div><h2 class="color_link">SCAN</h2></div>
<div><h2 class="color_link">RETUSCHEN</h2></div>
<div><h2 class="color_link">ANDRUCK</h2></div>
<div><h2 class="color_link">PDF</h2></div>
<div><h2 class="color_link">CTP</h2></div>
<div><h2 class="color_link">STACCATO</h2></div>
.............
.............
.............
........and so on........
</div>
function get_hover_color(i){
hover_color_array = ['54cacd','e84d3a','ff3384','a0388d','231599','0d958a','629B39','33811E','F04E00','F00200','D9008F','58dbb4','093C8B','AECB27','E5B208','74204f','C26A21','DB2C17','cccf78','166C64','9A1E6E','7EADC2','00A1CE'];
return hover_color_array[i];
}
$('.color_link').each(function(i){
$(this).hover(
function(){
var $this = $( this );
$this.data( 'prehovercolor', $this.css( 'color' ) ).css( {'color' : '#' + get_hover_color(i), 'cursor' : 'pointer' });
},function(){
var $this = $( this );
$this.css( 'color', $this.data( 'prehovercolor') );
});
});
Do this:
That should give you a range which will fall within the array at all times since it takes the remainder, which can only range from
0tohover_color_array.length-1