- This topic is empty.
Viewing 8 posts - 1 through 8 (of 8 total)
Viewing 8 posts - 1 through 8 (of 8 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › [Solved] Add a growing number class to list items and divs
I have a ul or list items and I wan to add classes to them dynamically like so.
...
How would I do this?
(also, the class names are generic examples, the important part is the number)
If you write your page in PHP (or ASP I guess) you can dynamically generate the classes or targets based on a loop counter – for ($i=1; $i++; $
No, php wont work, the lists and divs aren’t being generated dynamically. I have some jquery to make some list-items and some divs interact with each other and I need them to have a relatable class. I could hard code it, but if I have a lot it becomes a lot of work and the jquery wouldn’t be very dynamic.
You might want to look at an article I wrote on my blog:
http://jaredheinrichs.com/how-to-create-and-remove-html-elements-using-jquery.html
Thanks guys, I’ll try your solutions on Monday
@TT_Mark, thanks, it worked perfectly.
@jheinrichs79, thank you too
:)
Hey this helped me too! r00lz.