Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

169
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!