Have you ever had to manually code something that is sequential? Didn't you find it annonying? Well, here is a simple solution for you. This tutorial will show you how to use jQuery to add a sequent of CSS classes to create a graphical list. The second example will show you how to add a comment counter to a comment list using jQuery's prepend feature.
1a. Insert jQuery Code
First, download a copy of jQuery. In between the <head> tag, insert the jQuery code:
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#step li").each(function (i) {
i = i+1;
$(this).addClass("item" i);
});
});
</script>
The jQuery will output the source code as:

1b. CSS Code
Style the <li> element with a background image accordingly (step1.png, step2.png, step3.png, and so on..).
#step .item1 {
background: url(step1.png) no-repeat;
}
#step .item2 {
background: url(step2.png) no-repeat;
}
#step .item3 {
background: url(step3.png) no-repeat;
}
2a. Add Sequential Content
You can also use this technique to add sequential content using jQuery's prepend feature. The following example shows how you can add a counter number to a comment list.
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#commentlist li").each(function (i) {
i = i+1;
$(this).prepend('<span class="commentnumber"> #' i '</span>');
});
});
</script>
The code will add the <span class="commentnumber"> tag (with # + 1) to each <li> tag.

2b. CSS
Style the <li> element with position:relative and use position:absolute to place the .commentnumber to the top right corner.
#commentlist li {
position: relative;
}
#commentlist .commentnumber {
position: absolute;
right: 0;
top: 8px;
}


Oh boy do I like this… i am new jquery but I like what i see.
I have been playing with jQuery this week a lot, and I see what it is doing. It’s just taking me extra time to get it. But it is such a useful tool in generating CSS after the DOM has loaded!
This is another reason why i need to take the time and learn javascript/jquery – so I can come up with great idea’s like this.
great jquery examples..
good work
Very swish, I’ve always wanted to know how to do this, thanks very much for the information!
I’d have done this with php rather than javascript.
really nice and useful, thanks for the tip. best regards from Ralph (www.deprowebs.com)
Thanks this is very useful and helpful.
Regards
Omair Rais
(http://www.omairarts.com)
Great practical use of jQuery’s prepend() function. jQuery almost makes it too easy.
I use this method on my Indonesia Blog ;)
Nice post ! Very good ! Cool ! Tank´s
I’ve always wanted to know how to do this, thanks
What version of jQuery did you use? In local, width WordPress 2.7 jQuery version the sequential list doesn’t work.
(I’m working width your html file)
Ok, solved. jQuery.noConflict();
this is very useful and helpful article! thank you.
Yet another great quick tip, Thanks so much!
Great tutorial…
I will use this type listing in my website…
Thanks :)
wow that’s great, good tutorial.. thanks
Thanks very nice post….
I am just starting to use jQuery….