How can I have it so that each time the button is clicked the array is iterated through once? If I click it a second time, it should display the second array element, etc. until it iterates through the entire array.
JavaScript:
var images = [
"<img src='first.png' />",
"<img src='second.png' />",
"<img src='third.png' />",
"<img src='kitten.png' />"
];
var button = document.getElementsByClassName("btn-lg")[0];
button.addEventListener("click", function(){
for(i = 0; i < 5; i++) {
jQuery('.row.text-center').append(images[i]);
}
});
HTML:
<div class="row text-center">
<button type="submit" class="btn btn-lg btn-info">Click Here!</button>
</div>
jsfiddle: http://jsfiddle.net/KVs6S/1/
Thanks!