Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

170
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda