javascript - Adding unique class name to dynamically created elements/ JS / jQuery -


if have ten divs created dynamically, each 1 given class name 'createddiv' on creation. how can iterate through them after created , add unique class name each?

somthing like,

for each('.createddiv'){     var count = 1;         this.addclass('uniquename' + count);         count ++; } 

so end 10 divs follows,

('.createddiv .uniquename1') ('.createddiv .uniquename2') ('.createddiv .uniquename3') ('.createddiv .uniquename4') 

and on...

$('.createddiv').each(function(i){     $(this).addclass('uniquename' + i); }); 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -