Jak dodać elementy do listy ol/ul za pomocą JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
const songs= [ "1.mp3", "2.mp3", "3.mp3" ] const createSongList = () => { const list = document.createElement('ol') for(let i=0; i<songs.length; i++) { const item = document.createElement('li') item.appendChild(document.createTextNode(songs[i])) list.appendChild(item) } return list; } document.getElementById('songList').appendChild(createSongList()) |