Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

100
Vistas
Find Text and Clone with jQuery

I have this sorta working without the if statement, but I'm not sure why it's not working when I used the if statement and with $(this).

So this:

  if ($('.class--item:contains("Some random text items")')) 
  {
    $(this).parent().clone().appendTo($(".other--class"));
  }

Does not work. But this one does:

$('.class--item:contains("Some random text items")').parent().clone().appendTo($(".other--class"));

I'm not completely sure why one would work over the other, but I'm pretty sure I'm missing something. I'm also wondering if it's better to use one over the other as well since the if statement could offer some other "checking" rather than just "look for thing and clone it"

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

From the documentation you are using :contains() Selector but this does not return a boolean value. Instead, you should try jQuery.contains, which does return a boolean.

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda