我有这个定义随机颜色集的函数。
我的问题是定义变量 ( ) 以从对象var target
中选择新的颜色集。kuler
kuler: {
set0:['#499E8D','#85CC9F','#A4DEAB','#C8E8C7','#FFF6C9'],
set1:['#0F2440','#2C3F59','#518C8C','#94BEAC','#D9CAAD'],
set2:['#499E8D','#85CC9F','#A4DEAB','#C8E8C7','#FFF6C9'],
set3:['#0F2440','#2C3F59','#518C8C','#94BEAC','#D9CAAD'],
set4:['#499E8D','#85CC9F','#A4DEAB','#C8E8C7','#FFF6C9'],
set5:['#0F2440','#2C3F59','#518C8C','#94BEAC','#D9CAAD'],
set6:['#499E8D','#85CC9F','#A4DEAB','#C8E8C7','#FFF6C9']
},
setNewColourSet: function () {
rn=Math.floor(Math.random()*5);
for (i=0; i<4; i++){
var target = "project.kuler.set"+rn+"["+i+"]";
$('.kuler'+i).css('background-color',target);
/* works */// $('.kuler'+i).css('background-color',project.kuler.set4[i]);
}
}