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!