There are several ways to achieve this.
First try jQuery meta plugin . This allows you to embed JSON data in an element's class attribute. It validates and does not affect classes applied to the element. Your tr might look like this:
<tr class="some-class {uid:'12345', asMuchDataAsYouLike}">
Alternatively (if you don't mind using HTML5), use the data attribute ( here , here ):
<tr data-uid="12345">
Note. This will be validated as HTML5 if you use the correct DocType ( <!DOCTYPE html> ).
Edit (usage example):
HTML:
<tr data-uid="12345"> <td>Some Data</td> <td><button class="delete">Delete</button></td> </tr>
JavaScript:
$('button.delete').click(function(){ // obviously you'd do something different with the data ;) alert($(this).closest('tr').attr('data-uid')); });
Rowan source share