javascript - Generate a fingerprint (unique id) for each element in html -
i trying generate fingerprint each element in html body.
my first attempt looping elements in body , assigning id it.
for taking input tag assign
var = 0; $.each($('#container').find("input"), function(key, value) { $(this).attr("data-index", this.tagname.tolowercase() + "-" + i); });
but if add input tag dynamically in between 2 input tags, have re-assign data-index, not want do.
also not want keep track of last added id.
for second attempt thinking of generating fingerprint depending on input tag attributes, fingerprint unique page.
note that, time if page opened, same finger print value should generated.
is way correct? if yes then, how generate fingerprint?
if no then, please can 1 redirect me other way of doing it?
any appreciated.
thank in advance.
i going suggest guid (globally unique identifier), said wanted same value every time page generated. since that's case, suggest sort of "unique random number generator" uses constant seed. have no idea if such thing exists, such system give already-existing tags same fingerprint each time page loaded, , when tags dynamically added, new (but same previous page load) fingerprint generated.
the trick there create said "unique random" number generator. alternatively, use non-unique random number generator build guid. ie., "give me next 10 random numbers between 0 , 9" , there's id. it's exceedingly unlikely you'd generate 2 fingerprints of equal value way. don't forget have seed generator.
i don't know project, here's seedable generator supposedly: http://davidbau.com/archives/2010/01/30/random_seeds_coded_hints_and_quintillions.html
Comments
Post a Comment