odieatla
odieatla

Reputation: 1079

Clone Ancestor, and Look for Self's Copy in Cloned Ancestor

I'm pretty new to jquery and need some help.

I'm trying to clone a copy of the closest ancestor with class 'hidden' of $el and then look for $el's copy in the clone ancestor($hidden).

var $hidden = $el.closest('.hidden'),
    $substitute = $hidden
        .clone()
        .appendTo($hidden.parent());

Then I try to find $el's copy in $substitute. I tried this:

$substitute.find($el);

But it doesn't work..

Any help would be appreciated.

Upvotes: 1

Views: 53

Answers (1)

Derek
Derek

Reputation: 4751

You can try adding a data attribute to $el and then doing a $substitute.find('[your-data-attrib]') call

Upvotes: 1

Related Questions