i have an unknown number of section elements:
<section id="foo">
...
</section>
<section id="bar">
...
</section>
For each section which is present I need to add an attribute "data-serial" which is an integer starting at 0 and being incremented by 1 for each section present, for example the above would turn into:
<section id="foo" data-serial="0">
...
</section>
<section id="bar" data-serial="1">
...
</section>
<section id="bla" data-serial="2">
...
</section>
...
How can I achieve this using jQuery?
Thanks