Very interesting Marko. Passing data via class attribute probably isn't
the 'right' thing to do, but I've chosen to do it myself on occasion.
It's certainly a very useful function you've provided. I believe HTML5
will allow custom attributes beginning with 'data-' for this very purpose.
I would modify your regex slightly to:
The changes are the '\w' instead of 'a-zA-Z0-9', and the addition of
(?:) at the end. This isn't necessary at all, it just some dummy text to
insert between the '*' and '/' so the '*/' doesn't interfere with
Does the '-' separator for array values mean that if you have an array
of strings, none of the values can contain a '-'? Is there a better
character to use as a separator? I suppose you're limited if you don't
want the code to stop pages from validating?
Marko Zabcic wrote:
> Hi all,
> I've needed a way for storing data/variables on html elements and
> and example http://jsbin.com/ajohi (view source code)
> I would appreciate you opinion on this matter and also is there a way
> to optimize/shorten regex.
Advanced Web Construction Ltd
AJAX Blackjack - real-time multi-player blackjack game with no flash, java or
software downloads required - http://blackjack.webutils.co.uk
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to firstname.lastname@example.org
To unsubscribe from this group, send email to
For more options, visit this group at