I am student learning jQuery and my goal is to append each object within an array to 4 different buttons using the 4 objects within the indexes of optionArray. Currently it appends just a single button of the index i of the optionArray like this: Radio Head, Gorillaz, Coldplay, Arctic Monkeys.
I would like it to append each object individually within index i of optionsArray as 4 different buttons. For example:
- Radio Head
- Gorillaz
- Coldplay
- Arctic Monkeys
I am unsure how to do this...thank you for any help in advanced.
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] + ">");
});