Q:

JQuery: How replace text AFTER a nested tag? 

I'm trying to figure out the jQuery statement to rename "apple" with "orange:"
<a id="alvin" href="http://www.camille.com"><ins class="xxx">Anna</ins>apple</a>

Can this be done easily? 

A:

I removed the # from the ID, since it is not a valid ID character.  
Given that, try this:
Live Example: http://jsfiddle.net/u49wy/
var $contents = $('#alvin').contents();

$contents[$contents.length - 1].nodeValue = 'orange';

.contents() returns all the child nodes of the element, including text nodes. 
The code then grabs the last element node (which is a text node) and updates its nodeValue, which is how you update the value of a text node. 

.contents() - http://api.jquery.com/contents

A:

patrick beat me to it, but my solution is a little more dynamic in that it would select the text anywhere, even if there were tags on either side:
$('#alvin').contents().filter(function () {
    return this.nodeType == 3;
})[0].nodeValue = "orange";

It does this by filtering the contents so that only text nodes remain, and changes the first nodeValue to "orange".   
http://jsfiddle.net/ssRyB/

