[jQuery] replaceWith returns the replaced element
The replaceWith returns the JQuery element that was just replaced not
the replacer.
In the example below:
$('div#old').replaceWith('<div>new</div>').html()
The old div html is returned.
Is there another set of commands that would replace and return the new
element instead?
Thanks,
tchvil
A working example below:
- - - - - - - - - - - - - - - - - - -
<!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>