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"
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.