text() is really meant to retrieve text content as a string, and
append() is for appending elements, it's probably going through a lot
more hoops than just using text().

So it looks like the first way is the best way to do it, enjoy the
beauty of jQuery: extend it!

$.fn.textCopy = function(source) { // copy FROM
  return this.each(function(){
     $(this).text( $(source).text() );
  });
};

or

$.fn.textReplace = function(source) { // copy TO
  return this.each(function(){
     $(source).text( $(this).text() );
  });
};

cheers
- ricardo

On Sep 24, 3: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