On Tue, Sep 30, 2008 at 3:20 PM, Balazs Endresz
<
balazs.endresz@gmail.com> wrote:
>
> Someone came up with this recently:
>
> "Now, of course I can do this:
>
> $("#sandbox").text( $("a").text() );
>
> But I'd prefer to do this:
>
> $("a").text().appendTo("#sanbox"); "
why do you prefer this?
if I see "append" my interpretations is $("#sandbox").html(
$("#sandbox").html() + $("a").text() );
just curious, sorry...
>
>
http://groups.google.com/group/jquery-en/browse_thread/thread/bbd886b73e7768e1>
> I also think that this way would be a bit easier:
>
> $.fn._text = $.fn.text;
> $.fn.text = function( toTextNode ) {
> if( toTextNode === true )
> return
> this.pushStack( [ document.createTextNode( this._text() ) ] );
> return this._text( toTextNode );
> }
>
> And you could make it work by setting the first argument to true:
>
> $("a").text( true ).appendTo("#sanbox");
>
> Unfortunately that would also need a new method to replace the content
> like .text()
>
> Altogether it looks nice for me, though I'm not sure how intuitive is
> this?
>
> On Sep 26, 7:59 pm, "John Resig" <
jere...@gmail.com>