$.text(["someText"]) - What does it mean?
jQuery.text
does the heavy lifting for the implementation for the .text()
method -- it seems to be an undocumented function with the core functionality for .text()
, but missing some jQuery polish.
It's "imported" from Sizzle, where it appears as Sizzle.getText
.
Inspecting the jQuery source will reveal that the $(selector).text()
that you're familiar with, uses $.text
internally:
jQuery.fn.extend({
text: function( value ) {
return jQuery.access( this, function( value ) {
return value === undefined ?
jQuery.text( this ) :
this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
}, null, value, arguments.length );
},
It is an undocumented function (which means further jQuery revisions may drop it at will, without notifying you). You'll find its definition as such:
jQuery.text = Sizzle.getText;
Sizzle.getText
, in turn, is documented as "Utility function for retrieving the text value of an array of DOM nodes". Seeing as Sizzle.getText
is a documented feature, I would recommend using that rather than the jQuery shorthand, as I don't expect jQuery to drop Sizzle any time soon.
This function, then, is the piece of code that yields the text content of a DOM node. Your sorting method is sorting DOM nodes by the alphabetical order of their text content. I don't know why the author has decided to get the text of an array containing only one element ([a]
), rather than passing the element immediately (a
), which would work equally well.
After looking at your jsfiddle it appears it's a function for getting the text from an element, simular to .text()
console.log(a)
logged <td>28/02/2013</td>
While
console.log($.text[a])
logged 28/02/2013