I am trying to make a jquery markup list from div blocks and add id to each div one by one with numbers, e.g. 1,2,3,4,5 and so on.
For example, here is a list of div blocks:
<div class="my-blocks">
<div class="start"></div>
<div class="start"></div>
<div class="start"></div>
<div class="start"></div>
</div>
There can be any number of div blocks with the class "start". The end result should be like this:
<div class="my-blocks">
<div id="1" class="start"></div>
<div id="2" class="start"></div>
<div id="3" class="start"></div>
<div id="4" class="start"></div>
</div>
How can i do this? I just don’t understand where I can start using this functionality.
source
share