its a LOT less code, and a much better ux using HTML5:
you can do the other js too, but this should be your html starting point.
it works even with js disbled, and is more accessible than wresting with a script if you can't see everything at once, or at all for that matter...
BROWSER STATS [% share]
(2013/10/31) IE7:0.5, IE8:8.6, IE9:5.3, IE10:12.3, FF:17.7, CH:41.8, SF:8.1, MOBILE:20.4