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

202
Views
¿Cómo optimizo el código para no tener que escribir un número nuevo cada vez?

Tengo un código js como este:

 lightGallery($("#web1")[0], { selector: 'this', mobileSettings: { controls: false, showCloseIcon: true, download: false, } }); lightGallery($("#web2")[0], { selector: 'this', mobileSettings: { controls: false, showCloseIcon: true, download: true, } }); lightGallery($("#web3")[0], { selector: 'this', mobileSettings: { controls: false, showCloseIcon: true, download: true, } });

¿Cómo optimizo el código para no tener que escribir un número nuevo cada vez?

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

0

Puedes usar un bucle for :

 let lowerLimit = 1; let upperLimit = 3; for (let i = lowerLimit; i <= uppperLimit; i++) { lightGallery($("#web" + i)[0], { selector: 'this', mobileSettings: { controls: false, showCloseIcon: true, download: false, } }); }
about 4 years ago · Juan Pablo Isaza Report

0

Considera lo siguiente.

 $("[id^='web']").each(function(i, el){ lightGallery($(el)[0], { selector: 'this', mobileSettings: { controls: false, showCloseIcon: true, download: false, } }); });

Esto pasará por encima de cada uno que tenga un ID que inicie web y aplique el mismo código.

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!