Generally you can write it two way:
$('a').appendTo("#sandbox") or $("#sandbox").append("a")
but you can't do that with their text nodes,
and it feels easier if you write it in a chain.

I know what append does but as I said there's no such method that
replaces the content from this direction.

I like this but I'm not fully convinced either, just an idea :)

On Oct 1, 2:52 am, "Jaime Ochoa Malagón" <[EMAIL PROTECTED]> wrote:
> On Tue, Sep 30, 2008 at 3:20 PM, Balazs Endresz
>
> <[EMAIL PROTECTED]> 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/bbd886b...
>
> > 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" <[EMAIL PROTECTED]> wrote:
> >> I'm curious: Are there any pieces of code that use jQuery, right now,
> >> that you feel are unelegant or ugly? (Presumably ones that've already
> >> been optimized to the best of their ability.)
>
> >> One area of improvement that I was thinking of was something along the 
> >> lines of:
>
> >> // ugly
> >> $("#foo").val( $("#bar").val() );
>
> >> // a bit better
> >> $("#foo").val( $("#bar") );
>
> >> this would be an easy change, just make .attr() do something like:
>
> >> if ( arg.jquery )
> >>   val = arg.val() || arg.text() || "";
>
> >> Any other thoughts? I wonder if there are common cases that could be
> >> improved with some simple code additions to core.
>
> >> --John
>
> --
> Perhaps the depth of love can be calibrated by the number of different
> selves that are actively involved in a given relationship.
>
>                                         Carl Sagan (Contact)
>
>                                         Jaime Ochoa Malagón
>                                         Arquitecto de Soluciones
>                                         Cel: +52 (55) 1021 0774
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to