You can check my "Textnode Translator". I made a simple example where
it replaces textual emails.
That's just an example of course. I'd not rely on that code as it is.

http://flesler.blogspot.com/2008/05/textnode-translator-for-javascript.html

Alternatively, you can solve this with this Tokenizer, pretty simple
too:

http://flesler.blogspot.com/2008/03/string-tokenizer-for-javascript.html

Cheers
--
Ariel Flesler
http://flesler.blogspot.com

On Oct 2, 9:45 am, skankster <[EMAIL PROTECTED]> wrote:
> 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: [EMAIL PROTECTED]
> </div>
>
> With the help of jQuery it should look like this:
>
> <div id="myId">
>         Username: Johnny<br />
>         Email: <a href="mailto:";>[EMAIL PROTECTED]</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:"/>');
>
>  });
>
> I'm still at a loss as to how to select just the email address without
> the preceeding 'Email:' and am wondering if I'm not heading in a
> totally wrong direction with the orphan wrapping function.
>
> I gladly appreciate any assistance offered concerning this issue!

Reply via email to