I am trying to assign ids to my div on the page the div's are not created dynamically but are once written on the page and i need to assign random id's to those div that exist on my page. tried many thing but was unable to get solution.. And on the html page the div exists in the class called demo and to the div's i have assigned id=mydiv. And later the script is called and divs id is changed to random number from mydiv.. i am unable to add +1 to the next div. Tried jquery traversing as shown below nextall() but it doesnt add the +1 to the new div..
function handledivIds() {
var e = $(".demo #mydiv");
var t = randomNumber();
var n = "div-",t;
e.attr("id", n);
e.nextall().attr("id", n+1)
}
function randomNumber() {
return '' + new Date().getTime();
}