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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:14:51+00:00 2026-05-24T17:14:51+00:00

It seems to me that jQuery’s .data() function is more of a write-once store

  • 0

It seems to me that jQuery’s .data() function is more of a write-once store than true read-write-storage.

There does not seem to be a comfortable way of updating complex values.

Let’s suppose one wants to use some elements in a double-linked list (not my use case, illustrative purpose only).

It would be easy if I would do:

$elem.data('prev', $prev);
$elem.data('next', $next);

But I feel it is bad practice to pollute the “global” .data() namespace of an element.

So I would rather do:

$elem.data('list', {prev: $prev, next: $next});

But how do I now update prev?

In the first example, I would just do:

$elem.data('prev', $newPrev);

But in the in my opinion “nicer” way of doing things the only thing I can think of is something like this:

$elem.data('list', {prev: $newPrev, next: $elem.data('list').next});

This seems a lot more cumbersome to me and I suspect there is a better way, but so far I was unable to find anything.

How should I go about this?

  • 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-24T17:14:53+00:00Added an answer on May 24, 2026 at 5:14 pm

    When you call jQuery’s data method with one argument, you get a reference to the stored object, which you can update directly using regular . notation:

    $elem.data('list').prev = $newPrev;
    

    Thanks @balpha

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

Sidebar

Related Questions

It seems that i cannot access $(this) inside jquery ajax success function. please see
It seems that jQuery.browser is deprecated in the latest jQuery. The doc recommends that
It seems clear that jquery has become the standard low level JavaScript library. We
According to the definition of callback in JQuery pagination plugin's documents. It seems that
I have a form using jQuery that I need to manipulate the incoming data.
It seems that jQuery :contains selector does not work on IE8. Please see following
I came across this plain js ajax upload code (it seems that jquery $.post
It seems that jQuery validate plugin does not come with out of the box,
I am having problems using Gzip compression and JQuery together . It seems that
In my experience it seems that there is a lot of duplication of html

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.