Enumerating an ID, if not a class


Note, still experimental, but I’ve been playing around with such a widget for my Wiki project. As yet, yes, I know you can pull the pages out, not ‘put them back’, but I’m not worried about that at this point.

Rather, granted now we have items like React, just getting into, yet even aside from this… Is there any ‘convention’ for dynamically creating/assigning div class/ID names.

I mean this seems super useful at ‘run-time’. But of course the hard part is you can’t just assign an ‘index name’, like ‘0’, ‘1’, ‘2’ to reference them… So I’ve been giving them a ‘name’ and pulling off the last to chars in practice.

I guess I am wondering, is there a better, more established way, outside of a framework, to do this ?

Example (ignore animation, not finished):

P.s. Or I guess what I am asking is if you are dealing with an array or memory address it makes a lot of sense to go 0, 1, up… But here this is a ‘no-no’ as a naming convention.

Or I guess I should ask this in a slightly different way: I know how many divs I want to have here, but what if I were making them all up in JS, lets say I wanted 200 pages, what would at least be the most standard naming convention ?


You don’t need to call them anything them as long as all the things you are wanting to transform have the same class, and the rotation/margin/etc are consistent (or random). You have a set of identical elements, if you use $('.page') or document.querySelectorAll('.page') you get a collection of pages, each with an index, just set the styles you want to depend on index in the JavaScript. You just need to do very basic math on those styles.