I've got a table to which I'd like to add a attribute 'data-order' to every last child of every row. See the table below.

```
     <table id="table_id" class="display">
         <tbody>
           <tr>
            <td>Test</td>
            <td>255 500</td>
          </tr>
        </tbody>
    </table>

```

I'd like to add the value of the last td to the attribute.

```
Before : <td>255 500</td>
After  : <td data-order"255 500">255 500</td>

```

I use $(this).text() to get the value from the td but it doesn't seem to work the way I thought. I get weird data with multiple table rows included. I use this Javascript code to add the attribute. 

```
    $(document).ready(function() {
        $( '#table_id tbody tr td:last-child').attr( 'data-order', $(this).text());
    });
    </script>

```

What is wrong my code ? Thanks.