Hello我试图使用jQuery将数组的所有图像添加到现有的div标签中。每次我尝试这个时,我都会收到以下错误:“SyntaxError:Unexpected string literal”'/>“。预期')'结束参数列表。” 任何人都可以帮我这个吗?
</div>
<script>
var pictures = new Array(7);
var counter = 0;
$(document).ready(function() {
// sets up the array with some startin values
pictures[0] = new Image(100, 100);
pictures[0].src = "../Spel in jQuery/img/bubbles/blue.png";
pictures[1] = new Image(50, 50);
pictures[1].src = "../Spel in jQuery/img/bubbles/green.png";
pictures[2] = new Image(50, 50);
pictures[2].src = "../Spel in jQuery/img/bubbles/red.png";
pictures[3] = new Image(50, 50);
pictures[3].src = "../Spel in jQuery/img/bubbles/yellow.png";
pictures[4] = new Image(50, 50);
pictures[4].src = "../Spel in jQuery/img/bubbles/orange.png";
pictures[5] = new Image(50, 50);
pictures[5].src = "../Spel in jQuery/img/bubbles/purple.png";
pictures[6] = new Image(50, 50);
pictures[6].src = "../Spel in jQuery/img/bubbles/bom.png";
$(pictures).each(function() {
$('div#depionnen').append("<div><img src='"[0]"'</div>");
});
});
</script>
答案 0 :(得分:0)
$(pictures).each(function(key, value) {
$('div#depionnen').append("<div><img src='" + value.src + "' /></div>");
});