You made me think about confusing the maintainers :)
This would certainly do that but wouldn't break any code:

$.fn._text = $.fn.text;
$.fn.text = function( toTextNode ) {
  if( toTextNode === true )
    return
this.pushStack( [ document.createTextNode( this._text() ) ] );
  return this._text();
}

So you could do:

$("a").text(true).appendTo("#sanbox");

and even $("a").text(true).end() would return $('a')


On Sep 26, 3:17 pm, 703designs <[EMAIL PROTECTED]> wrote:
> Oh, and break everything that depends on the text method.
>
> On Sep 26, 9:16 am, 703designs <[EMAIL PROTECTED]> wrote:
>
> > I could also do something along these lines:
>
> > $.fn.oldText = $.fn.text;
> > $.fn.text = function() {
> >     return $(document.createTextNode(this.oldText()));
>
> > }
>
> > That is, of course, if I'd like to confuse the hell out of future
> > maintainers :)
>
> > On Sep 25, 1:15 am, Balazs Endresz <[EMAIL PROTECTED]> wrote:
>
> > > I think the easiest way is to write another plugin:
>
> > > $.fn.$text=function(){
> > >   return $( document.createTextNode( this.text() ) )
>
> > > }
>
> > > $("a").$text().appendTo("#sanbox");
>
> > > but you can extend the String prototype too:
>
> > > String.prototype.jqueryify=function(){
> > >   return $( document.createTextNode( this ) )
>
> > > }
>
> > > $('a').text().jqueryify().appendTo("#sanbox");
>
> > > On Sep 24, 8:27 pm, 703designs <[EMAIL PROTECTED]> wrote:
>
> > > > Because the text method returns a string, it's missing appendTo and
> > > > other methods. Now, of course I can do this:
>
> > > > $("#sandbox").text($("a").text());
>
> > > > But I'd prefer to do this:
>
> > > > $("a").text().appendTo("#sanbox");
>
> > > > What goes between text and appendTo? Or is the first example the best
> > > > way to do this?

Reply via email to