[jQuery] append mailto link to orphan plain text email address

[jQuery] append mailto link to orphan plain text email address


Hi,
I have a div that contains simple text data with line breaks. I want
to append a mailto link to the email address but so far I have not
been able to select the email.
The container looks something like this:
<div id="myId">
    Username: Johnny<br />
    Email: john@organization.com
</div>
With the help of jQuery it should look like this:
<div id="myId">
    Username: Johnny<br />
    Email: <a href="mailto:">john@organization.com</a>
</div>
My first intention was to use a filter like:
$('#myId').contents().filter(':contains("@")');
but I found out that I couldn't apply it since the container had no
children. So I used a function first to wrap the elements into span
tags and then applied 'find':
$.fn.orphans = function(){
    var ret = [];
this.each(function(){$.each(this.childNodes, function() {if
        (this.nodeType == 3 &! $.nodeName(this, "br") ) ret.push(this)})});
return $(ret);
}
$(document).ready(function() {
    $('#myId').orphans().wrap('<span/>');
$('#myId').find(':contains("@")').wrap('<a href="mailto:"/