I have a div with some text
<div>This is my initial text</div>
And I'd like to replace the text 'initial' with an input box which I already have created
Something like:
input=$("#myinput");
$("div").find("initial").replaceWith(input);
OR:
input=$("#myinput");
$("div").html().replace('initial',input);
But neither of these work
Any thoughts?
var inputString = document.createElement('div').appendChild(input[0]).innerHTML;. With the input as a string you can do a normal replace.<div>he's posted, and replace it with a text box. So the resulting HTML should be<div>This is my <input type="text" /> text</div>."<input type=\"text\" />"). The only reason why the OP's code didn't work was that he was trying to use jQuery object instead of a string. @SpikeX