4
I am studying the DOM of JS and had some difficulties. I need to show the elements of this vector as li tags of HTML: let nomes = ["Diego", "Gabriel", "Lucas"];
My code is this:
function gerar(){
let nomes = ["Diego", "Gabriel", "Lucas"];
let lista = document.querySelector('#lista');
let item = document.createElement('li');
for(let item of nomes){
lista.appendChild(item);
}
}
<input type="button" onclick="gerar()" value="Clique">
<ul id="lista">
</ul>
<script src="index.js"></script>
I would like help to complete the list and add the item
– GiiCastilho
I do not understand the meaning of this publication, but if you want to ask a new question Click the Ask New Question button. Read [Ask] and [Answer] to get a sense of how the page works. Also do our [tour].
– Augusto Vasques