Reputation: 177
I'm trying to replace a dom parent with its first child and deleting all other children. It's not working. I got error: "Node cannot be inserted at the specified point in the hierarchy"
$("#over1").replaceWith($(this).children()[0]);
Upvotes: 2
Views: 2401
Reputation: 22395
this
isn't referencing the #over1 element. Instead you should do:
$("#over1").replaceWith(function() { return $(':first', this); });
Upvotes: 4