Skip to content

Instantly share code, notes, and snippets.

@shingorow
Created August 24, 2017 07:31
Show Gist options
  • Save shingorow/3e09579bc90e15bdbd93d96dc0e49734 to your computer and use it in GitHub Desktop.
Save shingorow/3e09579bc90e15bdbd93d96dc0e49734 to your computer and use it in GitHub Desktop.
noUiSlider を複数箇所で使うためのメモ ref: http://qiita.com/shingorow/items/0846192703445634c7ff
window.onload = function() {
var sliders = document.getElementsByClassName('slider');
for (var i = 0; i < sliders.length; i++) {
var slider = sliders[i];
var options = {
range: {
min: [0, 10],
max: [100]
},
start: [20, 80],
}
noUiSlider.create(slider, options);
slider.noUiSlider.on('update', function(values, handle) {
var parentNode = this.target.parentNode; // this.target で update した slider を取得できる
parentNode.getElementsByClassName('first')[0].value = values[0];
parentNode.getElementsByClassName('second')[0].value = values[1];
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment