Thank you, Ricardo. Although I don't like to think of dead cats... ;)
On 8 Okt., 21:04, ricardobeat <[EMAIL PROTECTED]> wrote: > Here's a quick short function that will do the job: > > $('#deadcat').each(function(){ > var lnk = $(this).html().replace(/([\w-]+@([\w-]+\.)+[\w-]+)/, '<a > href="mailto:$1">$1</a>'); > $(this).html(lnk); > > }); > > hope that helps, > - ricardo > > On Oct 7, 3:06 am, "David C. Zentgraf" <[EMAIL PROTECTED]> wrote: > > > > > What about using a regular expression match/replace? Seems like an > > obvious candidate. > > > On 7 Oct 2008, at 04:38, skankster wrote: > > > > No one? > > > > On 2 Okt., 14:45, 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!