It's actually quite cool: appendTo
is dynamically defined relative to append
. That's what is going on in these lines:
jQuery.each({
appendTo: "append",
prependTo: "prepend",
insertBefore: "before",
insertAfter: "after",
replaceAll: "replaceWith"
}, function( name, original ) {
jQuery.fn[ name ] = function( selector ) {
var ret = [],
insert = jQuery( selector ),
parent = this.length === 1 && this[0].parentNode;
...
Which makes sense, as the two functions are almost the same in functionality, just reversed in which effects which.
Should you include that file, then pass the function $('html').appendTo
and analyze what it references, you get this:
function ( selector ) {
var ret = [],
insert = jQuery( selector ),
parent = this.length === 1 && this[0].parentNode;
...
Do you recognize that code? If you continue down the first code block I mentioned, you'll see they're almost identical. The first block dynamically generates the code for appendTo
, as well as a few others in the same vein.