This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes JQuery retrieving attribute's original values  Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "JQuery retrieving attribute Watch "JQuery retrieving attribute New topic
Author

JQuery retrieving attribute's original values

jeroen dijkmeijer
Ranch Hand

Joined: Sep 26, 2003
Posts: 131
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.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15357
    
    6
Same answer as the other place.

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56180
    
  13

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.

[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: JQuery retrieving attribute's original values
 
Similar Threads
tool tip on multiselect option using Jquery
jquery and css trying to retrieve a value from a .js file
Reset range slider values
Toolkit for AJAX?
How to POST without leaving the page?