Hello,
I need to capture all of the text of the body and replace it after I have ran it against a reg expression.
I have tried the following ways already (these are without the expression applied, just trying for basic html replacement here)....
Method 1
var html = $('body').html();
$('body').replaceWith(html);
### the problem with this method is it doens't return the <body> tags when it replaces it since the jQuery replaceWith function actually deletes the code it finds, I've also tried manually inserting the tags into the parameters of the function but it doenst work.
The way to fix it would seem something like this,
$('body').html().replaceWith($('body').html());
but that will fail because replaceWith is not a function of html.
Method 2
var html = $('body').parents().html();
$('body').parents().replaceWith(html);
### the problem with this method is it includes everything in the head also, so obviously it fails when it tried to include the head twice.
Method 3
$('body').children().each(function() {
$('this').replaceWith($(this).parents().html())
});
### this doesnt work either, here I'm trying to find the html by going from the child node...
My body code is here...
<body>
<h1>my header</h1>
<div id="wrapper">
<div class="col1">
<div id="ref">
<p>some text</p>
</div>
</div>
</div>
</body>
Any ideas?