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

177
Views
how to loop through local storage to get text for a text area
$("#hour8 .description").val(localStorage.getItem("hour8"));
$("#hour9 .description").val(localStorage.getItem("hour9"));
$("#hour10 .description").val(localStorage.getItem("hour10"));

this is the current code that I have minus 8 more hours, how can I loop through this to clean it up?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you're trying to reduce the amount of duplicated code you could loop through each hour and programatically target the html element and get the data for that element from localStorage.

[1,2,3,4,5,6,7,8,9,10].forEach(hour => {
  $(`#hour${hour} .description`).val(localStorage.getItem(`hour${hour}`));
})
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!