Como o .text () da jQuery funciona internamente?
Eu rapidamente tentei encontrar a implementação na fonte do jQuery, mas só encontreiesta que na verdade não parece defini-lo completamente.
Da fonte jQuery
jQuery.fn.extend({
text: function( text ) {
if ( jQuery.isFunction(text) ) {
return this.each(function() {
return jQuery(this).text( text.call(this) );
});
}
if ( typeof text !== "object" && text !== undefined ) {
return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
}
return jQuery.getText( this );
},
Ninguem sabe?
Esclarecimento:
Eu sei comousar isto. Eu só quero saber como obter o texto de um elemento no jQuery quando o jQuery não estiver disponível.