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
Post a Comment