Skip to content

Instantly share code, notes, and snippets.

@rgdonohue
Last active January 3, 2016 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rgdonohue/8465271 to your computer and use it in GitHub Desktop.
Save rgdonohue/8465271 to your computer and use it in GitHub Desktop.
html5 input range slider
<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<style>
@import url(http://fonts.googleapis.com/css?family=Raleway);
body {
background: #e3e3e3;
font-family: Railway, sans-serif;
}
#wrapper {
background: white;
width: 90%;
min-height: 300px;
margin: 40px auto;
padding: 40px;
border-radius: 5px;
}
#output {
width: 40px;
display: inline-block;
margin: 0 15px 0 0;
padding: 6px 8px;
text-align: center;
box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.4);
}
#range-slider {
width: 400px;
}
#range-slider::-moz-range-thumb {
padding: 3px;
}
#range-slider:active::-moz-range-thumb {
background: orange;
}
</style>
</head>
<body>
<div id="wrapper">
<output id="output"></output>
<input id="range-slider" type="range">
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
var max = 17,
min = 4,
step = 1,
output = $('#output').text(min);
$("#range-slider")
.attr({'max': max, 'min':min, 'step': step,'value': String(min)})
.on('input change', function() {
output.text(this.value);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment