Get DOM element hash in javascript?
hash, javascript, jquery, object
Solution
Try this :
var uid = function (i) {
return function () {
return 'prefix-' + (++i);
};
}(0);
Usage :
uid(); // "prefix-1"
uid(); // "prefix-2"
if (!el.id) el.id = uid(); // "prefix-3"
Problem
In case the element doesn't have an ID attribute, I want to generate some kind of unique identifier that identifies the element. Is there some function that can get me the object hash of the DOM element object, similar to spl_object_hash in PHP ? That would be unique enough.