| 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
|
|
Same answer as the other place.
Eric
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56180
|
|
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]
|
 |
 |
|
|
subject: JQuery retrieving attribute's original values
|
|
|