```
<div class="content">

    <div>
        <input type="text" name="newname[name]0"/>
        <div>
           <input type="text" name="newname[utility]0"/>
           <div>
               <textarea name="newname[text]0"></textarea>
           </div>
        </div>
    </div>

    <div>
        <input type="text" name="somename[name]1"/>
        <div>
           <input type="text" name="somename[utility]1"/>
        </div>
        <div>
           <textarea name="somename[text]1"></textarea>
        </div>
    </div>

    ... etc ...

</div>

```

What's an efficient way to use [jquery's selector](http://api.jquery.com/input-selector/) to reorder all input elements (input, textarea) based on their current position? ie, if a user deletes `newname[name]0` div from the parent element, then `somename[name]1` would be moved up and should be renamed to `somename[name]0`. 

I think it should be something along the lines of:

```
$(".content").children().each( function(index, val) {
    val.find(":input").each(function(i, inputvalue) {
       // Somehow extract the current name of inputvalue and replace the number with index?
    });
});

```