Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9243137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:44:35+00:00 2026-06-18T08:44:35+00:00

I’ve recently come across a code sample I had to use, and I was

  • 0

I’ve recently come across a code sample I had to use, and I was able to use it, but I didn’t quite understand exactly what was going on.

Here’s part of the code:

.sortElements(function(a, b){
    return $.text([a]) > $.text([b]) ? 
        inverse ? -1 : 1 
        : inverse ? 1 : -1;
}

I know that this function is deciding which element should be sorted first out of a and b, and I know that inverse is deciding the sort order, but I don’t know what $.text([a]) is doing. Is it parsing a as text kind of like parseInt(a) and Date.parse(a)?

Google could not help me. I’ve also looked into the jQuery site and all I’ve found is

$(selector).text(), $(selector).text(newText) function.

Here’s the Fiddle I’m basing my code from http://jsfiddle.net/gFzCk/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:44:35+00:00Added an answer on June 18, 2026 at 8:44 am

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am confused How to use looping for Json response Array in another Array.
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.