Create a JavaScript array and loop through it

Create a JavaScript array and loop through it:

var theBeatles = [
"John Lennon",
"Paul McCartney",
"George Harrison",
"Ringo Starr"
];

for (i = 0; i < theBeatles.length; i++) {
$('#myDiv').append(theBeatles[i]+'
');
}
It's only fair to share...Tweet about this on TwitterShare on FacebookEmail this to someoneShare on Google+
This entry was posted in JavsScript, jQuery and tagged , , , , . Bookmark the permalink.