Reputation: 9293
I'm trying to place an image from an array into a div.
arralegro =[ "01.png", "02.png", "03.png", "04.png"];
n=2;
var goImg = 'alegro/' + arralegro[n];
alert (goImg); //correct - `alegro/02.png`
$('#divR').empty();
$("#divR").prepend('<img id="slide" src=' + goImg + '/>'); // here is something wrong
Firebug says - 404 Not Found
. But the image is there.
$("#divR").prepend('<img id="slide" src="alegro/02.png"/>'); // works this way
Upvotes: 0
Views: 70
Reputation: 390
I think you might be forgetting the double quotes around the src attribute. Try this line:
$("#divR").prepend('<img id="slide" src="' + goImg + '" />'); // here is something wrong
Upvotes: 2
Reputation: 14343
You're missing the quotes:
$("#divR").prepend('<img id="slide" src="' + goImg + '"/>');
Upvotes: 7