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

158
Views
¿Cómo reorganizar elementos usando jQuery?

¿Cómo reorganizar elementos usando jQuery?

Código original:

 <p id="paragraph1">1</p> <p id="paragraph2">2</p> <p id="paragraph3">3</p> <p id="paragraph4">4</p> <p id="paragraph5">5</p>

Después de reorganizar (poner p3 en el lugar de p2)

 <p id="paragraph1">1</p> <p id="paragraph3">3</p> <p id="paragraph2">2</p> <p id="paragraph4">4</p> <p id="paragraph5">5</p>
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Puedes usar .insertBefore() :

 $("#paragraph3").insertBefore("#paragraph2");

Ejemplo un poco más elaborado (al hacer clic en un párrafo se mueve hacia arriba):

 $("p").click(function() { $(this).insertBefore($(this).prev()); });

Puedes probar ambos ejemplos aquí.

over 4 years ago · Santiago Trujillo 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!