I'm struggling to figure out what I'm doing incorrectly. My goal is to set the width of an image to a random value between 0 and 100%. Can someone help me identify my mistake?
function updateProgressBar() {
$("body").append("<div class='main_div'></div>");
var numberOfBars = Math.floor(Math.random() * 10) + 1;
for(var i = 0; i < numberOfBars; i++){
$(".main_div").append("<div class='statusbar'></div>");
$(".statusbar:nth-child(" + numberOfBars + ")").append("<img src='project_status.gif'>");
var randomWidth = Math.floor(Math.random() * 100) + 1;
$(".statusbar:nth-child(" + numberOfBars + ") img").css({ "width": randomWidth + "%" });
}
}