Is there a way to hash the html dom element for use on a map?

I am trying to save some data against the html dom element and do not want to rely on the attributes set in the element. So, is there a way for the html dom hash element to be used on the map?

Example: I want to be able to do the following in javascript:

Map[Hash(DIV1)] = somedata; 
+4
source share
1 answer

You can add data directly to the div.

 var nextID = 1; var hash = function(div){ div.hashID = div.hashID || ('hashID_' + (nextID++)); return div.hashID; } 
+3
source

Source: https://habr.com/ru/post/1403888/


All Articles