• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JQuery retrieving attribute's original values

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Not sure, whether this is the right forum (or website) but the moderator is the author of my favorite book.
I would like to know whether it's possible to retrieve the original value of an attribute after it has been changed, by dom manipulation.
Just asked the question on the jquery channel, the only possibility I was told, is to store the values upon loading of the document.
Is there another way, via the jquery api?

regards,
Jeroen.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Same answer as the other place.

Eric
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm afraid not. A DOM element's attributes are stored in a NodeList object tacked onto the element. When the attribute value is changed, the value in the node list is changed and the original value is lost.

If you need to be able to reference the original values, then it would be easy in the ready handler to copy the attribute values (the .each() method knows how to iterate over a node list) to an object that stores the values as properties, and then use the .data() method to tack it onto the DOM element for later reference.

P.S. Thanks for the thumbs-up on the book.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic