Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I build a gracefully-degrading HTML5 Range?

I'd like to use the <input type='range' /> from HTML5 for browsers that support it and degrade to a <select /> if not. I'm using Ruby-on-Rails, so failing all else, I could do something like this on the server-side.

I would prefer, though, to have something more inline with the idea of progressive enhancement done via Javascript. Bonus points if it's JQuery.

like image 292
James A. Rosen Avatar asked Feb 11 '10 17:02

James A. Rosen


1 Answers

Check out Modernizr, it will tell you if range is supported. I believe the technique is to create a range input and check it's type — if it is still "range" then it is supported. Otherwise it should report "text" which is the fallback in other browsers.

like image 73
Ben Boyle Avatar answered Oct 21 '22 03:10

Ben Boyle