I have a <div> with some options in a data-options attribute:
<div class="slider" data-options="container: value, speed: 1000, edgePadding: 45, lazyload: true">
This attribute contains the arguments I need for every <div> with a .slider class.
I'm saving those arguments into an options variable with:
var options = value.dataset.options;
Then I need to pass those options to a function tns for each .slider element:
var forEach = function (array, callback, scope) {
for (var i = 0; i < array.length; i++) {
callback.call(scope, i, array[i]);
}
};
var sliders = document.querySelectorAll('.slider');
forEach(sliders, function (index, value) {
var options = value.dataset.options;
let slider = tns({
/************ PARAMETERS GO HERE ***********/
});
});
How can I achieve that?