You can put data inside the class attribute (like <div class="someclass { id: 234 }"></div>), it's perfectly valid. The class attribute is not meant for presentation only according to the HTML/ XHTML specs. http://plugins.jquery.com/project/metadata
Or, use the HTML5 doctype <!DOCTYPE html> (with valid mark-up obviously) and the new data-xx attribute, that will give you standards mode in all browsers and perfectly valid attributes: <td class="trigger" id="trigger_${record.ID}" data-recordID="$ {record.ID}">${record.name}</td> $('td.trigger').click(function(){ alert( $(this).attr('data-recordID') ); }); See http://ejohn.org/blog/html-5-data-attributes/ for more info. cheers -- ricardo On Jul 2, 12:45 pm, John Newman <john.newma...@gmail.com> wrote: > Hello > > First off if this is a double post I apoligize, I sent my first > message an hour ago and it is not showing up. Anyway: > > I've wondered if there is a way to do this for a while. Perhaps I am > missing something or should use a different approach altogether. > > Say I have a dynamic page that generates some td elements. The > syntax here is freemarker but you can easily envision your favorite > serverside text generating language instead. > > <table id="records"> > <thead><th>Name</th></thead> > <tbody> > [#list records as record] > <tr> > <td class="trigger" id="trigger_${record.ID}" onclick="showDetails > (${record.ID})">${record.name}</td> > </tr> > [/#list] > </tbody> > </table> > > <script type="text/javascript"> > function showDetails(recordID) { > // normally an ajax post but you get the idea > window.location = '/record?recordID=' + recordID > } > </script> > > Now I want to get that onclick out of there and bind it using jquery, > but i haven't been able to figure out if there is a way to get the > parameter there. Apart from putting it in some attribute and looking > at it. Is there a cleaner way? > > <script type="text/javascript"> > $(document).ready(function() { > $('#records td.trigger').click(function() { > window.location = '/record?recordID=' + ??? how do i get > that > }); > }); > </script> > > I know I could look at the elements attributes, something like > this.attr("id").substring().etc().etc() .. but sometimes there are > many parameters to the javascript fn to generate the post and that > approach doesn't seem to viable. and there isn't really a standard > attribute to use that makes sense for that anyway. So how do I do > this? > > Thanks