give an element a unique id based on its dom position

This is a very useful code to give a unique id.

$("div").attr("id", function (arr) {
return "div-id" + arr;
})
This will display the id.
.each(function () {
$("span", this).html("(ID = '<b>" + this.id + "</b>')");
});

Leave a Reply