Javascript examples for jQuery:Array
Loop through an array and add every object to ul as an li
<html lang="en"> <head></head> <body> <div id="pokeList"> <ul> </ul> </div> <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> <script> $(function () {//from w w w . j av a 2s .co m let pokemonList = ['a', 'b', 'c', 'd']; for (let i = 0; i < pokemonList.length; i++) { $("#pokeList ul").append(`<li>${pokemonList[i]}</li>`); } }); </script> </body> </html>