HTML:
<div class="rating" id = "r1"></div>
<div class="rating" id = "r2"></div>
<div class="rating" id = "r3"></div>
<div class="rating" id = "r4"></div>
<div class="rating" id = "r5"></div>
Js (using jquery 1.10.1) :
<script type = "text/javascript">
$(document).ready(function(){
var rate = new Array();
rate[1] = "r1";
rate[2] = "r2";
rate[3] = "r3";
rate[4] = "r4";
rate[5] = "r5";
var r = <?php echo $rate;?>
for(var i=1; i<=r;i++){
var k = rate[i];
$('#'+k).css{('background-image': 'url(images/star_green.png)')};
}
});
</script>
Basically what i want to do using this code is to modify the background of the first x divs (number provided in my db). I know that the js variable r takes the right value...same for the k variable...the only thing that i think is not working is the part where the background is set. I tested it using direct values (without the +k part) and it didn't work the either. The page is located in root and the images folder is next to it.
Any suggestions?
PS: The Js script is placed on the page after the divs.