Skip to content

Instantly share code, notes, and snippets.

@dhoko
Last active December 9, 2015 21:18
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 dhoko/4329127 to your computer and use it in GitHub Desktop.
Save dhoko/4329127 to your computer and use it in GitHub Desktop.
Dynamically displaying input values using Javascript & CSS ::after
/*
Display value with ::after (CSS)
input[type="range"] {position: relative}
input[type="range"]::after {
content: attr(value);
position: absolute;
left: 105%;
top: 0;
color: #555
}
*/
/*
div#range>input*n
*/
var displayRangeValue = function() {
var div = document.getElementById('range');
div.addEventListener('change', function(e) {
if("input" === e.target.nodeName.toLowerCase() && "range" === e.target.type) {
e.target.setAttribute('value', e.target.value);
}
});
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment