Let’s dynamically add IDs on our DIV tag, depending on the number of DIVs
<div class="panel" id="">
...
...
</div>
<div class="panel" id="">
...
...
</div>
<div class="panel" id="">
...
...
</div>
the result that we would like to achieve is using jquery
<div class="panel" id="1">
...
...
</div>
<div class="panel" id="2">
...
...
</div>
<div class="panel" id="3">
...
...
</div>
i tried to do a code like this but it is not working
$panel.each(function(i) {
$(this).attr('id', ($(i+1)));
http://jsfiddle.net/rjptR/