1
Hello, I’m wanting to insert an item(li), into an html list(ul) This item is an object, or property of an object. PS: I want a list to appear for example containing this data of the object I created
function produto(nome, tipo, preco, descricao){
this.nome = nome;
this.tipo = tipo;
this.preco = preco;
this.desc = descricao;
}
const myproduct = new produto("Biquini", "rendinha", 140, "ideal para praia")
const body = document.querySelector('body');
const list1 = document.querySelector('ul');
const item = document.createElement('li')
const escrever = innerHTML = "Meu produto: " + " " + myproduct.nome;
const nomeProduto = myproduct.nome;
body.appendChild(list1);
body.appendChild(item);
<!DOCTYPE html>
<html>
<head>
<title>teste</title>
</head>
<body>
<p id="demo"></p>
<div class="produtos">
<ul>
</ul>
</div>
</body>
</html>
Excellent!!! was exactly what I was thinking :D
– Felipe Medeiros