how to get the width of each previous element and sum them up (after loading the page)
Then put the value in the data attribute of each item
This is the jsfiddle code http://jsfiddle.net/jSfKJ/2/
so how to make this code
<ul> <li style="width:130px">Num 1</li> <li style="width:150px">Num 2</li> <li style="width:140px">Num 3</li> <li style="width:175px">Num 4</li> <li style="width:100px">Num 5</li> </ul>
to be like that -
<ul> <li style="width:130px" data-num="0">Num 1</li> <li style="width:150px" data-num="130">Num 2</li> <li style="width:140px" data-num="280">Num 3</li> <li style="width:175px" data-num="420">Num 4</li> <li style="width:100px" data-num="595">Num 5</li> </ul>
This image to more clearly explain what I want | 
I hope I explained what I need.
source share