roflol
roflol

Reputation: 637

Select jQuery cloned element

I am trying to select element which has been cloned

$("THINGS TO CLONE").clone().appendTo("CONTAINER");

And it should have looked

> <CONTAINER>
> 
> <CLONED THING> <CLONED THING> <CLONED THING>
> 
> </CONTAINER

I made it but these things are invisible for selecting.

Upvotes: 2

Views: 10234

Answers (1)

Richard Neil Ilagan
Richard Neil Ilagan

Reputation: 14747

That doesn't make sense. If you've cloned your elements correctly, and inserted them into the DOM somehow, they're perfectly selectable using jQuery.

If you want to select your cloned elements, however, one way you can go about it is caching the original in-memory cloned object before slapping it into your DOM.

var clone = $('#foo').clone();

// do stuff with clone
clone.doBackflips();

// append it to the DOM
clone.appendTo('#container');

Upvotes: 9

Related Questions