Questions tagged [replacewith]

JQuery .replaceWith() method. Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed.

JQuery .replaceWith() method. Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed.

The .replaceWith() method, like most jQuery methods, returns the jQuery object so that other methods can be chained onto it. However, it must be noted that the original jQuery object is returned. This object refers to the element that has been removed from the DOM, not the new element that has replaced it.

As of jQuery 1.4, .replaceWith() can also work on disconnected DOM nodes.

Source:http://api.jquery.com/replaceWith/

316 questions
6
votes
1 answer

Replace element and preserve attributes

The following almost works in replace all instances of span[data-type="yesno"] with lis, but I'd like to also preserve the attributes, classes, etc. Is there a way to carry over the attributes in the same way as the…
emsoff
  • 1,585
  • 2
  • 11
  • 16
5
votes
3 answers

jQuery .replaceWith() alternate

My site uses jQuery 1.4.2. The problem is .replaceWith() does not work in IE6 & IE7 in jQuery 1.4.2. Is there an alternate method that is supported by IE6 & IE7 in jQuery 1.4.2? The fiddle is here: http://jsfiddle.net/8CEwf/1/ I know, it may not…
5
votes
4 answers

jQuery removes Font Awesome Icon

I am using Font Awesome and jQuery in an experiment, after an animation, the jQuery replaces a loading icon in a list by a check, and the text changes too. However, when I remove the jQuery replaceWith method, the icon stays: HTML:
FlipFloop
  • 1,233
  • 1
  • 14
  • 25
4
votes
3 answers

jQuery.replaceWith doesn't take