我是学生学习jQuery的一个阵列中的多个对象和我的目标是在一个阵列中添加的每个对象使用optionArray的指标内的4个对象4层不同的按钮。目前,它追加optionArray这样的指数我的只是一个单一的按钮:射频前端,街头霸王(Gorillaz),酷玩乐队,北极猴子。追加与jQuery
我想它的每个对象附加内,4个不同的按钮optionsArray的索引i单独。例如:
- 射频头
- 街头霸王(Gorillaz)
- 酷玩
- 狂卖
我不确定如何做到这一点?感谢您对先进的任何帮助。
JS:
window.onload = function() {
$('#start').html('<div class="text-center"><button type="button" class="btn btn-default">Start</button></div>');
};
var questionArray = ["This bands second album went platinum 5 times in the UK and double Platinum in the US."];
var optionArray = [["Radio Head", "Gorillaz", "Coldplay", "Arctic Monkeys"], []];
var answerArray= ["Gorillaz"];
var imageArray= ["http://cdn3.pitchfork.com/artists/1767/m.65d9c64d.jpg", "http://crowningmusic.com/storage/rA7GUFFoBCtT8Jg4L1tv.png", "", "", ""];
var count = 0;
$("#start").on('click', function() {
$(this).css("display","none");
for (var i = 0; i < questionArray.length; i++) {
$("#question").html(questionArray[i]);
for (var j = 0; j < 4; j++) {
$("#options").append("<button>" + optionArray[i] + "</button>");
}
}
// $("#holder").html("<img src=" + questionArray[count] + ">");
});
你的目标是很难理解“我想这是每一个指标指数中我附上为4层不同的按钮。” –
这是你在找什么? https://jsfiddle.net/36zck6dk/ – talentedandrew