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

106
Views
How do I increment the moment in my loop to be added to next div
for (let index = 0; index < $(".hour").length; index++) {
  console.log("test");
  var hour = moment().hour(9).format("h");
  $(".row").find(`[data-hour]`).text(hour);
}

This posts 9 in my first div. I would like my next dive to post 10 etc... I can't figure out how to increment my moment.

image linked of what it looks like in browser

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

0

Option 1:

for (let index = 0; index < $(".hour").length; index++) {
  console.log("test");
  var hour = moment().hour(index).format("h");
  $(".row").find(`[data-hour]`).text(hour);
}

Option 2: (Probably more performant)

let myMoment = moment();
for (let index = 0; index < $(".hour").length; index++) {
  console.log("test");
  var hour = myMoment.hour(index).format("h");
  myMoment.add(1, 'h');
  $(".row").find(`[data-hour]`).text(hour);
}

https://momentjs.com/docs/#/manipulating/add/

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!