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

103
Views
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 answers
Answer question

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 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!