Created
August 24, 2017 07:31
-
-
Save shingorow/3e09579bc90e15bdbd93d96dc0e49734 to your computer and use it in GitHub Desktop.
noUiSlider を複数箇所で使うためのメモ ref: http://qiita.com/shingorow/items/0846192703445634c7ff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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