FYI, when I need to attach metadata to a non-empty element, I do it
with an invisible child element. This results in some extra HTML, but
I think that's as elegant as it can get until HTML5 becomes
mainstream.

<style type="text/css">
.metadata { display: none; }
</style>

<a href="#">show details<span class="metadata">foobarbaz</span></a>

$("a").click(function() {
var metadata = $(this).children(".metadata").text();
} );

On Sep 22, 4:41 pm, WalterGR <walte...@gmail.com> wrote:
> On Sep 22, 4:35 pm, Ricardo <ricardob...@gmail.com> wrote:
>
> > This doesn't make any sense. If you're already using jQuery why keep
> > your handler in the HTML?
>
> Because I need to pass additional information to the event handler in
> a clean way.  (i.e. rather than hacks using various attributes on the
> anchor.)  Is there a non-hackish way to do this?
>
> Thanks for the code snippet - that's what I was looking for.
>
> Walter

Reply via email to