javascript - save data for an HTML element such that it can be accessed later -


everything i've read says not save custom properties or attributes html dom elements. i'm trying figure out how else should save properties/attributes element such can access them later.

originally thinking of using element key in hash js converts hash keys string won't work.

use case:

function do1(element) {     var w = element.style.width;     element.style.width = "200px";      // want save w variable element somewhere/somehow }  function do2(element) {     // want able w variable saved earlier element } 

i thought of using element's id element won't have id can use , can't set 1 because there might other js dynamically sets ids elements.

why not use data attributes? they're intended storing data on element.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -