Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

171
Visualizações
How can i get the value of a created element if its not an input in JS

So I created an item name where i display as the name says the item name and same for item money, and then i have a button that i want to get the values of the item name and item money but it gives me 0

    // Update table
    var expenseTitle = document.createElement("li");
    expenseTitle.innerText = expenseName.value;
    expenseTitle.classList.add("title-item");
    expenseTitle.id = "item-title";
    table.appendChild(expenseTitle);

    var expenseMoney = document.createElement("li");
    expenseMoney.innerText = expenseAmmount.value + "$";
    expenseMoney.classList.add("value-item");
    table.appendChild(expenseMoney);

    var editBtn = document.createElement("button");
    editBtn.innerHTML = "<i class='fas fa-edit'></i>";
    editBtn.classList.add("edit-btn");
    editBtn.onclick = () => {
      // here when i log the expenseTitle value gives me 0
      console.log(expenseTitle.value);
      // same stands for expenseMoney
      console.log(expenseMoney.value);
      expenseTitle.remove();
      expenseMoney.remove();
      editBtn.remove(), deleteBtn.remove();
    };
    table.appendChild(editBtn);
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda