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

174
Visualizações
Trying to describe div in JavaScript but did not do it

My project is to create website of 'Daily item Rate List' so i want to create different tabs like vegetables rate, fruit rate etc. So problem is i want to add card for different items like when i click on vegetables tab different types of vegetables appear on vegetables log. but i dont know how to define div in JavaScript. I want to create different function for different items like function vegetables(){ } and then inside function i want to place different card of different item like tomato rate card ,onion card etc so in short i want to do create such function and then call it by button just like we call normall function but i do not know to declare div and do such thing and how to call it so will you please help me out

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

I think you're just looking for createElement():

document.createElement("div");

This is really Javascript 101, so I would recommend getting familiar with the basics.

w3schools - createElement()

about 4 years ago · Juan Pablo Isaza Relatório

0

There are 2 basic options:

  • [discouraged]
    Use a script element in the html body <script>document.write("<div />");</script>
  • Use the DOM API to add elements:

Code example for the latter:

let e_new = document.createElement("div");
    // Create a new div element for the html document in the context of which this code executes 

document.querySelector('body').append(e_new);
    // Add the new element as the last element on the document, or ...

document.querySelector('#my-parent-element').append(e_new);
    // ... add the new element as the last child an existing element having the `id` attribute of `my-parent-element`.
about 4 years ago · Juan Pablo Isaza Relatório
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