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 6701873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:59:10+00:00 2026-05-26T06:59:10+00:00

While going through the source, I noticed that ‘toggle’ supposedly uses jQuery._data to store

  • 0

While going through the source, I noticed that ‘toggle’ supposedly uses jQuery._data to store the state of the element. I examined the jQuery.cache object in chrome and found that the element’s data object had yet another object under it prepended by the word jQuery with a number that I’m guessing uniquely identifies it. However, I saw no data regarding the state of the element. Simply {olddisplay: 'block'}. Any clues as to the purpose of jQuery._data and how it works per se?

I’ve been staring at the source all day …. please don’t tell me to view the source. My eyes and brain will thank you.

  • 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-05-26T06:59:10+00:00Added an answer on May 26, 2026 at 6:59 am

    jQuery uses _data in order to set the ‘pvt’ flag for data it stores on the object. The pvt is used so that when you request public data from the object, pvt data is not returned. This is to keep jQuery’s internal use of the .data() mechanism (like what toggle does) from effecting the public use of .data().

    You can see this declaration in the jQuery source:

    // For internal use only.
    _data: function( elem, name, data ) {
        return jQuery.data( elem, name, data, true );
    },
    

    Which just calls jQuery.data and forces the fourth parameter (which is privacy) to be true. When retrieving data, if the pvt flag is set, then it is retrieved in a slightly different way. The public interfaces to .data() do not expose the pvt flag.

    You can see an example of pvt handling here in this part of jQuery.data():

    // An object can be passed to jQuery.data instead of a key/value pair; this gets
    // shallow copied over onto the existing cache
    if ( typeof name === "object" || typeof name === "function" ) {
        if ( pvt ) {
            cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name);
        } else {
            cache[ id ] = jQuery.extend(cache[ id ], name);
        }
    }
    

    and then later in that same function, this comment is pretty descriptive:

    // Internal jQuery data is stored in a separate object inside the object's data
    // cache in order to avoid key collisions between internal data and user-defined
    // data
    if ( pvt ) {
        if ( !thisCache[ internalKey ] ) {
            thisCache[ internalKey ] = {};
        }
        thisCache = thisCache[ internalKey ];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

while going through some of the mili source code I came across a struct
While going through one project, I have seen that the memory data is 8
All, While going through some of the files in Java API, I noticed many
While going through university and from following the development of SO, I've heard a
While going through many resources on multithreaded programming, reference to volatile specifier usually comes
While going through a Zend tutorial , I came across the following statement: Note
I'm working on a Open Source project on SourceForge that uses Subversion. A few
while going through video tutorials for mvc2 which i downloaded from microsoft's website, the
While going through one of the problems in Python Challenge , I am trying
I found a lot of Optimization Options here While going through them I found

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.