Bug in replaceWith?
Bug in replaceWith?
Hello
I've got some code that iterates over a bunch of elements, found by a class and wraps them all with some template html:
- $('.'+clazz).each(function () {
- var element = $(this).clone();
- var wrappedElement = $($(templates[clazz]).children()[0]).clone();
- wrappedElement.find('#content').replaceWith(element);
- // this should just be - $(this).replaceWith(wrappedElement); - jQuery bug?
- if (this.id != '') { $('#' + this.id).replaceWith(wrappedElement); } else { $(this).replaceWith(wrappedElement); }
});
line 5 shows that I should just be able to say: $(this).replaceWith(wrappedElement);
but it doesn't work if the element has an id.
Has anyone else seen this? The work-around I have is fine, but surely it shoudln't be that way