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

190
Views
¿Cómo usar el operador ternario en el método jquery animate cuando está dentro de una cadena?

basado en una variable, quiero darle lógica al método .animate en jquery. ¿Cómo puedo hacer eso?

mi código:

 $('#' + id) .delay(shortIntervalTime) .animate({opacity: 'show'}) .delay(longIntervalTime) .fadeOut(3000, function () { if (flag === true) { cycle1(nextId, false); } else { vdoList = insertIntoArray(vdoListTwo); console.log({ vdoList }); addDisplay(firstAd, true, vdoList); } });

entonces si id === 'block3' quiero usar .animate({opacity: 'show', bottom: '100px'}) y en otro caso quiero usar .animate({opacity: 'show'})

¿Cómo puedo hacer esto?

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

0

Desea pasar condicionalmente el objeto al método de animate . Así que simplemente haz esto como:

 .animate( id === 'block3' ? { opacity: 'show', bottom: '100px' } : { opacity: 'show' }, )

Puede lograr con el operador ternario como:

 $('#' + id) .delay(shortIntervalTime) .animate( id === 'block3' ? { opacity: 'show', bottom: '100px' } : { opacity: 'show' }, ) .delay(longIntervalTime) .fadeOut(3000, function () { if (flag === true) { cycle1(nextId, false); } else { vdoList = insertIntoArray(vdoListTwo); console.log({ vdoList }); addDisplay(firstAd, true, vdoList); } });
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!