[jQuery] replaceWith returns the replaced element
Hi,
replaceWith returns the JQuery element that was just replaced.
In the example below:
$( 'div#old' ).replaceWith( '<div>new</div>' ).html()
It is the html of the old div that is returned.
Is there another set of commands to get the new one returned?
Thanks,
tchvil
Here is a working example:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/
TR/html4/strict.dtd">
<html>
<head>
<script type="text/javascript" src="http://jqueryjs.googlecode.com/
files/jquery-1.2.6.pack.js"></script>
<title>ReplaceWith Chain</title>
</head>
<body>
<div id="old">old</div>
<script type="text/javascript">
alert($('div#old').replaceWith('<div>new</div>').html());
</script>
</body>
</html>