Personally I would hate large amounts of logic in my attributes like that. I much think that properly formatted and structured JavaScript solves this problem much better. Especially when the same logic applies to two elements and you can create a function for it.