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

67
Views
Usando jQuery contiene con matriz

En lugar de escribir esto un montón de veces (que funciona):

 $('.this--class:contains("Some text")').parent().clone().appendTo($(".other--class")); $('.this--class:contains("Other text")').parent().clone().appendTo($(".other--class")); $('.this--class:contains("More text")').parent().clone().appendTo($(".other--class"));

Si trato de averiguar si puedo colocar los elementos de texto en una matriz y luego recorrerlos usando jQuery y luego hacer que se clone en .other--class .

mi ejemplo:

 var items = [ "Some text", "Other text", "More text" ]; $.each(items, function (index, value) { $(".this--class:contains(value)").parent().clone().appendTo($(".other--class")); }

Si hago un console.log(value); Puedo ver que expulsa los elementos correctos en la consola. Simplemente no estoy seguro de la forma correcta de hacer que :contains() reconozca ese texto, o si necesito hacerlo de manera diferente. En general, solo busca una manera más fácil de no tener que escribir lo mismo una y otra vez.

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