I’m trying to put a number in a list of elements – a dynamically increasing number – like:
1. text
2. text
3. ...
...
So far I have this:
var c = {
current: 0,
count: function () {
this.current++
}
}
$('.box').each(function (index) {
$(".number").text(c.current + 1);
c.count();
});
- see jsfiddle. But what am I missing? how do I give each element its own number?
Thanks.
http://jsfiddle.net/Qzk3P/4/, you forgot to add context parameter, see example below:
notice
thisEDIT: I’ve added another example with css-property counter, you may also like it: http://jsfiddle.net/Qzk3P/6/