mok_ku
mok_ku

Reputation: 236

jQuery: cloned element gets removed when the original element is removed

I have a form that is containing one input.
When a user is clicking on a button, this input will be cloned and the clone will be inserted after the original input.

The user is also able to remove the clone.

My problem is, when I remove the original element that used to create the clone, all cloned element are removed too.

I only want to remove the target input that the user is choosing.

Upvotes: 1

Views: 649

Answers (1)

Andrew Spode
Andrew Spode

Reputation: 647

A cloned element is not linked to the original element. What is more likely is that the selector you are using to delete an element has too broad a scope and so is deleting them all. This can also happen if you are selecting by ID and, as a commenter has suggested, you have cloned the ID to each element as well.

Without some code snippets, it's hard to fully diagnose the issue.

Upvotes: 1

Related Questions