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 
multi-line commenting.

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?


- Kev

Marko Zabcic wrote:
> Hi all,
> I've needed a way for storing data/variables on html elements and
> retrieving then through javascript. Here is the result: 
> and example (view source code)
> I would appreciate you opinion on this matter and also is there a way
> to optimize/shorten regex.
> Thanks,
> Marko
> >

Kevin Porter
Advanced Web Construction Ltd

AJAX Blackjack - real-time multi-player blackjack game with no flash, java or 
software downloads required -

You received this message because you are subscribed to the Google Groups 
"Prototype &" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Reply via email to