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 id
s elements.
why not use data attributes? they're intended storing data on element.
Comments
Post a Comment