jquery loop through elements by incrementing ID
<p>I have about a dozen events to check and all selectors are similarly (iteratively) named. How could I shorten this routine?</p>

<pre><code>$(document).ready(function() {
    $(document).on('click','#del_od1', function() {
        $('#change_od1').val('YES');
        $('#span_od1').html('(Deleted)');
        $('#status_od1').val('DELETED');
    });
    $(document).on('click','#del_od2', function() {
        $('#change_od2').val('YES');
        $('#span_od2').html('(Deleted)');
        $('#status_od2').val('DELETED');
    });
    $(document).on('click','#del_od3', function() {
        $('#change_od3').val('YES');
        $('#span_od3').html('(Deleted)');
        $('#status_od3').val('DELETED');
    });
});
</code></pre>

<p>This question is poorly named. Could someone also suggest a more precise title and I'll change it to that before accepting the answer.</p>

<hr>

<p>EDIT:</p>

<p>An entire table structure is echoed out in response to an ajax call.  The top of the table is like this:</p>

<pre><code>$r = '
    &lt;table id="DocTable"&gt;
        &lt;tr&gt;
            &lt;th width="170"&gt;Document Title&lt;/th&gt;
            &lt;th width="170"&gt;MetShare FN&lt;/th&gt;
            &lt;th width="50"&gt;Action&lt;/th&gt;
            &lt;th width="50"&gt;Delete&lt;/th&gt;
        &lt;/tr&gt;';
</code></pre>

<p>Followed by a couple of irrelevant rows containing information as requested in the call. Then this is appended to the previous bit, and the whole thing echoed out as <code>echo $r;</code>.</p>

<pre><code>$rest_docs =  $aProj['all_project_docs'];
$ocnt = 0;
if ($rest_docs !== ''){
    $ocnt = $ocnt + 1;
    $aRest_docs = explode('?',$rest_docs);
    foreach($aRest_docs as $doc){
        $aDoc_parts = explode('|',$doc);

        $r = $r . '
        &lt;tr&gt;
            &lt;td&gt;'.$aDoc_parts[0].'&lt;/td&gt;
            &lt;td&gt;
                &lt;span id="span_od' . $ocnt . '"&gt;
                    &lt;a href="'.$aDoc_parts[1].'" target="blank"&gt;
                    '. $aDoc_parts[1] .'
                    &lt;/a&gt;
                &lt;/span&gt;
                &lt;input type="hidden" id="status_od' . $ocnt . '" name="status_od' . $ocnt . '"&gt;
            &lt;/td&gt;
            &lt;td&gt;
                &lt;a id="change_od' . $ocnt . '" class="normal" href="#"&gt;change&lt;/a&gt;
                &lt;input type="file" id="if_od' . $ocnt . '" name="if_od' . $ocnt . '" style="display:none"&gt;
                &lt;input type="text" style="display:none"&gt;
            &lt;/td&gt;
            &lt;td&gt;
                &lt;a href="#" id="del_od' . $ocnt . '"&gt;delete&lt;/a&gt;
            &lt;/td&gt;
        &lt;/tr&gt;';
    }
}

echo $r;
</code></pre>
