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

  • SEARCH
  • Home
  • 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 975525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:35:53+00:00 2026-05-16T03:35:53+00:00

Is it possible and smart to store extra data inside a jQuery object? Right

  • 0

Is it possible and smart to store extra data inside a jQuery object?

Right now I have objects that contain some data but these objects also have a visual representation of that data. This works but I have a lot of code to keep them both in sync.

For example if you delete an object from the dom I also have to delete the related object from the object array. Deleting is fairly simple but it gets a little more complicated if I start sorting/moving the objects around.

  • 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-16T03:35:54+00:00Added an answer on May 16, 2026 at 3:35 am

    You can use $.data() for this 🙂

    For example:

    $.data(element, 'varName', value);      //store
    var value = $.data(element, 'varName'); //get
    

    Or use the object method .data():

    $("#ElementID").data('varName', value);      //store
    var value = $("#ElementID").data('varName'); //get
    

    This doesn’t store the data on the object, rather it stores it in $.cache (try it in your console on this page), but it’s associated with the object, via this[$.expando].

    However if you call .empty() that removes an object, or .remove(), it’ll do the cleanup for you. You can also call .removeData() or $.removeData() to remove it directly.

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

Sidebar

Ask A Question

Stats

  • Questions 498k
  • Answers 498k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If the syntax was wrong it would tell you that,… May 16, 2026 at 12:08 pm
  • Editorial Team
    Editorial Team added an answer What do you mean you are getting null back? Firstly,… May 16, 2026 at 12:08 pm
  • Editorial Team
    Editorial Team added an answer In ApplicationController, you can do the following: before_filter :prepare_new_session def… May 16, 2026 at 12:08 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a list of objects and each and every object in the list
I'm using GData's AuthSub so that my administrative application doesn't need to store user/password
I need some smart enough thumbnail generation lib to use it in my java
Anyone know if it is possible to wrap the xtick labels in matplotlib? Right
I've implemented a server side application that records timestamps when records are created and
This is my problem: I need to store a lot of log messages and
I have to port a smaller windows forms application (product configurator) to an asp.net
My question is one I have pondered around when working on a demanding network
Possible Duplicates: Should we support IE6 anymore? IE6: To support or not to support.
Optimizations such as constant propagation are possible across functions within the same compilation unit

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.