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
0
votes
1 answer

Datepicker after replaceWith()

I can make a jQuery datepicker work if the textfield is created when the website is loaded but if I make it appear with a .replaceWith() function, it wont work. Here is my code when it just appears when the website is…
Oskar Persson
  • 6,605
  • 15
  • 63
  • 124
0
votes
2 answers

JQuery replacing $(this) in .click() leads to something unclickable?

I have the following code : $('div[class^=locked_]').click(function() { var newThis = $(this) ; $(this).load(url + " #" + $(this).attr("id"), function() { var loaded = $(this).children("#" + $(this).attr("id")) ; …
Adrien Gorrell
  • 1,291
  • 3
  • 14
  • 28
0
votes
2 answers

jQuery cloning and removing div doesn't add div back in

I found a piece of code that helped me with my original issue: I have a section of tabbed content where some content has video in it. When you play the video, then choose another tab, the video continues playing the in the background. Common issue…
Shelly
  • 370
  • 1
  • 3
  • 11
0
votes
2 answers

html jquery function don't work but replaceWith does

I have realy strange behavior. I have this code (I remove unrelated code). $(function() { function get_translations() { $('#translations tr').not(':eq(0)').remove(); var item = { context: "1:…
jcubic
  • 61,973
  • 54
  • 229
  • 402
0
votes
3 answers

How to use jQuery replaceWith to replace varying number elements

I have a varying number of elements with the same class name:

I want to replace each of these with a new set of elements with the same class name, but there could be more or fewer elements:
fehays
  • 3,147
  • 1
  • 24
  • 43
0
votes
4 answers

replacewith jquery

I have list generated by ajax call like this
  • some val
  • some val
  • some val
with a setinterval, the same ajax call will create a list like this
tv4free
  • 287
  • 3
  • 17
0
votes
1 answer

use jquery to load different divs into popup div

I have a popup div that I need to load a bunch of different divs with custom ids. for example say we have recipepopup1 recipepopup2 and recipepopup3 each of which have a recipebutton1, recipebutton2 recipebutton3 respectively and then we have…
katie bekell
  • 361
  • 5
  • 23
0
votes
1 answer

Can't get the right selector for .replaceWith method

Having some problems with this piece of code, i want to replace the piece of html code that defines what the background is upon selecting a choice from the radio button options. I can't seem to get the selector right. …
0
votes
4 answers

CSS style not applied on content replaced with jQuery

I have a div that I'm replacing dynamically with jQuery. I do something like this: $.get(url, function(result){ $("#myDiv").replaceWith($(result)); } The request is made correctly and the markup is loaded with no problem, but even if the content…
willvv
  • 8,439
  • 16
  • 66
  • 101
0
votes
2 answers

How can I replace a DOM node and wrap it after?

I have a div which I'm replacing with a textarea like: var $targetDiv = $('#the-div'); var $newDiv = $('#the-new-div'); $targetDiv.replaceWith($newDiv); Which would turn:
into:
How would I…
bob_cobb
  • 2,229
  • 11
  • 49
  • 109
-1
votes
1 answer

jquery replacewith function: cannot replace with

When I click on #demo_3, it simply eliminates the button. However, if inside the replaceWith() I put a

O, hai!

, O, hai! will appear. $(document).ready(function(){ $("#demo_3").click(function(){ $("#ind_3").replaceWith('
-1
votes
5 answers

Replace elements group with a particular element in python3

I have a list of over 50 elements. These elements are lowercase and uppercase alphabets, numbers, special characters. eg. sample_list = ['1', '0', 'b', 'B', '2', '6', 'a', '7', '9', '5', 'c', 'd', '4', 'A', 'C', 'f', 'D', 'F', '3', 'C', '8', 'A',…
Cool Breeze
  • 738
  • 2
  • 10
  • 26
-1
votes
1 answer

How to replace an HTML tag with only an opening DIV and close it later on

I have tried to find answers and only stumbled over replaceWith Automatically Closes the Tag and Replace HR Element with Open Div - both finding first and last element and wrapping a div around. In my case we have an HTML with multiple text in p…
Avatar
  • 14,622
  • 9
  • 119
  • 198
-1
votes
1 answer

Load replaceWith text change before page change

hopefully a quick and easy one. I have a small sample of code (below) that when a class is found in the body, the page h1 title changes to another title. The project I'm working on needs lots of different templates, so I am using jquery to get this…
-1
votes
1 answer

Change input type, from radio button to checkbox, jquery

First of this is my very first jQuery script if you have any suggestions don’t be shy. I'm trying to do the following. I have 3 columns of radio buttons. With a checkbox above. When I check one of those checkboxes the column changes from radio…
PHPeter
  • 567
  • 6
  • 19