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
-1
votes
5 answers

How can I replace the entire HTML of a page, or its body content, via an AJAX call's success callback?

I need to replace the entire HTML of a page, or its body content (rather than append more html to the existing content). The accepted answer here showed me how to return data, but adding it to "body" doesn't quite work. This is the jQuery I have…
-1
votes
1 answer

Why isn't this li transforming on replaceWith?

$('li').click(function() { $(this).replaceWith('
cool stuff'); }); When i use this code, the text in the middle shows up, but not the text box I'm looking for. How do i fix this?
WillingLearner
  • 7,106
  • 6
  • 34
  • 51
-1
votes
1 answer

ReplaceWith in class jquery

i got multiple input type file and i want to make a checking if the file max size exceeds the limit it clears the value of the input file. if i use the id if runs perfectly but when i change it to class i got error like this Uncaught ReferenceError:…
Julius Limson
  • 526
  • 9
  • 29
-1
votes
1 answer

How to "reset" the .replaceWith function in jQuery?

How do I "reset" the .replaceWith function so that the html, css and javascript are returned back to their original state? The idea is to have an icon replace the text when the user clicks on "contact", and when the user clicks on "back" button, the…
-1
votes
2 answers

jQuery replacewith anchor tag to span tag

I'm trying to have an anchor tag removed and replaced with a span tag but keep the class attr. I have this code but it is showing "undefined" for the class. $("#wprmenu_menu").find('li:has(ul) > a').replaceWith(function() { var Qthis =…
vnetkc
  • 116
  • 9
-1
votes
3 answers

Replacing all characters with a certain character by loops

For this classwork(as you can see i didn't finish it cause i have no clue how to start this) I am suppose to make a program that when the user enters his/her string, plus the character that replaces all characters with, it changes the characters of…
-1
votes
2 answers

Alternating divs after x seconds with jquery in wordpress

The following code I am using works fine and it does what I want, but it just seems really sloppy and wanted to implement the 'replaceWith' function to make it cleaner. I want to show div1 for 10 secs, hide the div, and then show div2 for 10 secs,…
Paul
  • 227
  • 1
  • 3
  • 14
-1
votes
1 answer

replaceWith jquery not works

var gethtml = $("#topmenu > li.l89 a").text().split(' ')[1].replaceWith('Any World'); The text is not changing even after using replaceWith as shown above.
Dest
  • 678
  • 2
  • 9
  • 27
-2
votes
3 answers

jquery replace html tag before loading page

I want to replace a HTML tag with another, when loading a page, without showing original tag. For example I have a tag with class named header.

Original Tag

and I want to replace with another tag without showing original…
Hamid N.CH
  • 57
  • 1
  • 8
-2
votes
3 answers

Is it possible to use replaced divs to start a function?

If you take a look at the dev site here: www.tmwlsh.co.uk/wlsh you will see that there are four boxes. Once you click the down arrow in each box, the arrow changes to an up arrow. The changing of the arrow is all done in jQuery and the 'up arrow…
TMWLSH
  • 17
  • 4
-2
votes
1 answer

Fragment Replacement

Is there any way to replace the main layout in the navigation drawer with the Activity which extends AppCombatActivity not the Fragment. Because whenever I do so it gives me the error that : Wrong 2nd argument type.…
Alok
  • 8,452
  • 13
  • 55
  • 93
-2
votes
1 answer
-2
votes
1 answer

alternative replaceWith() jquery without losing second element

example
example 1
example 2
when I use that code, I lost exp2 ( mean example 2…
Sandhi
  • 89
  • 2
  • 11
-3
votes
1 answer

batch find file, replace with another file, that is supplied

I need help creating a batch file to find multiple files named the same thing in 100's of files and replace the with a different file... Alternatively, is there a program that will do this if I select the 2 different files that will search and…
-3
votes
1 answer

How to replace multiple selectors at a time using replaceWith()

I want to replace certain divs with other divs. But I want to do it all at a time. divs_to_replace.eq(-1).after(new_divs).end().remove(); So I thought I should use replaceWith() instead as it does that at…
Alvaro
  • 9,247
  • 8
  • 49
  • 76
1 2 3
21
22