Can you direct us to some JavaScript that does this? This style of implementation is used by Dan Cedarholm and Jason Santa Maria. I think they would confirm it's best used in CSS. Haha
I only say it's better to implement in js because css forces you to tie behavior to markup in this case. Good implementation separates content/markup (html), presentation (css), and behavior (js).