Skip to content

Instantly share code, notes, and snippets.

View jawu's full-sized avatar

jawu jawu

  • plusquam studio
View GitHub Profile
@dudleystorey
dudleystorey / auto-generated range ticks
Created April 27, 2014 07:17
Creates an auto-generated series of option values to generate ticks for Chrome & IE10 range sliders. slider requires min,max,step and list attributes.
function ticks(element) {
if (element.hasOwnProperty('list') && element.hasOwnProperty('min') && element.hasOwnProperty('max') && element.hasOwnProperty('step')) {
var datalist = document.createElement('datalist'),
minimum = parseInt(element.getAttribute('min')),
step = parseInt(element.getAttribute('step')),
maximum = parseInt(element.getAttribute('max'));
datalist.id = element.getAttribute('list');
for (var i = minimum; i < maximum+step; i = i + step) {
datalist.innerHTML +="<option value="+i+"></option>";
}